minor UI and adaptive lighting tweaks
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "pico/stdlib.h"
|
||||
#include "pico/multicore.h"
|
||||
@@ -13,7 +14,7 @@
|
||||
|
||||
static absolute_time_t lastSend;
|
||||
static absolute_time_t lastRead;
|
||||
static uint16_t adc_value = 0;
|
||||
static uint8_t adc_value = 0;
|
||||
static bool mute = false;
|
||||
|
||||
static unsigned char buf[BUF_SIZE];
|
||||
@@ -144,7 +145,7 @@ static struct key key_list[NUM_KEYS] =
|
||||
void get_light() {
|
||||
// get ADC reading from LDR every 500ms
|
||||
if ( absolute_time_diff_us(lastRead, get_absolute_time()) >= 500000) {
|
||||
adc_value = adc_read();
|
||||
adc_value = log2(adc_read());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -186,9 +187,9 @@ static void send_color(uint8_t dev_addr) {
|
||||
buf[buf_idx+5] = 0x0A;
|
||||
switch (key_list[key_idx].mode) {
|
||||
case RGB_MODE_ADAPTIVE: // adjust brightness based on LDR ADC reading
|
||||
buf[buf_idx+6] = (ADC_MAX-adc_value)*key_list[key_idx].red/ADC_MAX;
|
||||
buf[buf_idx+7] = (ADC_MAX-adc_value)*key_list[key_idx].green/ADC_MAX;
|
||||
buf[buf_idx+8] = (ADC_MAX-adc_value)*key_list[key_idx].blue/ADC_MAX;
|
||||
buf[buf_idx+6] = (ADC_MAX_LOG2-adc_value)*key_list[key_idx].red/ADC_MAX_LOG2;
|
||||
buf[buf_idx+7] = (ADC_MAX_LOG2-adc_value)*key_list[key_idx].green/ADC_MAX_LOG2;
|
||||
buf[buf_idx+8] = (ADC_MAX_LOG2-adc_value)*key_list[key_idx].blue/ADC_MAX_LOG2;
|
||||
break;
|
||||
case RGB_MODE_MUTE:
|
||||
if (mute) {
|
||||
|
||||
Reference in New Issue
Block a user