typos and remove unused code
This commit is contained in:
@ -27,6 +27,9 @@ int main(void)
|
|||||||
uint8_t font_width;
|
uint8_t font_width;
|
||||||
uint8_t font_height;
|
uint8_t font_height;
|
||||||
|
|
||||||
|
printk("Starting Mellifera version %s...\n", APP_VERSION_STRING);
|
||||||
|
// printk("Board: %s\n", BOARD);
|
||||||
|
|
||||||
dev = DEVICE_DT_GET(DT_CHOSEN(zephyr_display));
|
dev = DEVICE_DT_GET(DT_CHOSEN(zephyr_display));
|
||||||
if (!device_is_ready(dev))
|
if (!device_is_ready(dev))
|
||||||
{
|
{
|
||||||
@ -84,14 +87,14 @@ int main(void)
|
|||||||
const struct device *ina, *bmp, *hdc;
|
const struct device *ina, *bmp, *hdc;
|
||||||
|
|
||||||
ina = DEVICE_DT_GET(DT_NODELABEL(ina231));
|
ina = DEVICE_DT_GET(DT_NODELABEL(ina231));
|
||||||
if (!device_is_ready(dev))
|
if (!device_is_ready(ina))
|
||||||
{
|
{
|
||||||
LOG_ERR("Device %s not ready\n", ina->name);
|
LOG_ERR("Device %s not ready\n", ina->name);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bmp = DEVICE_DT_GET(DT_NODELABEL(bmp388));
|
bmp = DEVICE_DT_GET(DT_NODELABEL(bmp388));
|
||||||
if (!device_is_ready(dev))
|
if (!device_is_ready(bmp))
|
||||||
{
|
{
|
||||||
LOG_ERR("Device %s not ready\n", bmp->name);
|
LOG_ERR("Device %s not ready\n", bmp->name);
|
||||||
return 0;
|
return 0;
|
||||||
@ -201,74 +204,5 @@ int main(void)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int ret;
|
|
||||||
unsigned int period_ms = BLINK_PERIOD_MS_MAX;
|
|
||||||
const struct device *sensor, *blink;
|
|
||||||
struct sensor_value last_val = {0}, val;
|
|
||||||
|
|
||||||
printk("Zephyr Example Application %s\n", APP_VERSION_STRING);
|
|
||||||
|
|
||||||
sensor = DEVICE_DT_GET(DT_NODELABEL(example_sensor));
|
|
||||||
if (!device_is_ready(sensor))
|
|
||||||
{
|
|
||||||
LOG_ERR("Sensor not ready");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
blink = DEVICE_DT_GET(DT_NODELABEL(blink_led));
|
|
||||||
if (!device_is_ready(blink))
|
|
||||||
{
|
|
||||||
LOG_ERR("Blink LED not ready");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = blink_off(blink);
|
|
||||||
if (ret < 0)
|
|
||||||
{
|
|
||||||
LOG_ERR("Could not turn off LED (%d)", ret);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
blink_set_period_ms(blink, BLINK_PERIOD_MS_MAX);
|
|
||||||
|
|
||||||
printk("Use the sensor to change LED blinking period\n");
|
|
||||||
|
|
||||||
while (1)
|
|
||||||
{
|
|
||||||
ret = sensor_sample_fetch(sensor);
|
|
||||||
if (ret < 0)
|
|
||||||
{
|
|
||||||
LOG_ERR("Could not fetch sample (%d)", ret);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = sensor_channel_get(sensor, SENSOR_CHAN_PROX, &val);
|
|
||||||
if (ret < 0)
|
|
||||||
{
|
|
||||||
LOG_ERR("Could not get sample (%d)", ret);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((last_val.val1 == 0) && (val.val1 == 1))
|
|
||||||
{
|
|
||||||
if (period_ms == 0U)
|
|
||||||
{
|
|
||||||
period_ms = BLINK_PERIOD_MS_MAX;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
period_ms -= BLINK_PERIOD_MS_STEP;
|
|
||||||
}
|
|
||||||
|
|
||||||
printk("Proximity detected, setting LED period to %u ms\n",
|
|
||||||
period_ms);
|
|
||||||
blink_set_period_ms(blink, period_ms);
|
|
||||||
}
|
|
||||||
|
|
||||||
last_val = val;
|
|
||||||
|
|
||||||
k_sleep(K_MSEC(100));
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user