添加智能灯固件代码

This commit is contained in:
kerwincui
2021-07-13 17:14:51 +08:00
parent 332f74dd17
commit ecc0b91b8b
2568 changed files with 229441 additions and 0 deletions

View File

@@ -0,0 +1,2 @@
idf_component_register(SRCS "example_unit_test_main.c"
INCLUDE_DIRS ".")

View File

@@ -0,0 +1,40 @@
/* Example application which uses testable component.
This example code is in the Public Domain (or CC0 licensed, at your option.)
Unless required by applicable law or agreed to in writing, this
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied.
*/
#include <stdio.h>
#include "esp_system.h"
#include "testable.h"
/* This application has a test subproject in 'test' directory, all the
* interesting things happen there. See ../test/main/example_idf_test_runner_test.c
* and the makefiles in ../test/ directory.
*
* This specific app_main function is provided only to illustrate the layout
* of a project.
*/
void app_main(void)
{
const int count = 32;
const int max = 100;
printf("In main application. Collecting %d random numbers from 1 to %d:\n", count, max);
int *numbers = calloc(count, sizeof(numbers[0]));
for (int i = 0; i < count; ++i) {
numbers[i] = 1 + esp_random() % (max - 1);
printf("%4d ", numbers[i]);
if ((i + 1) % 10 == 0) {
printf("\n");
}
}
int mean = testable_mean(numbers, count);
printf("\nMean: %d\n", mean);
free(numbers);
}