Skip to content

Commit

Permalink
calibration fix
Browse files Browse the repository at this point in the history
  • Loading branch information
vascofazza committed Jan 4, 2021
1 parent 9e513c8 commit 532c52d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
21 changes: 18 additions & 3 deletions nixie_firmware/src/cloxie_firmware.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ enum CYCLE

int8_t cycle = CYCLE::CLOCK;
bool sleeping = false;
bool calibration = false;

LedPatternList clock_patterns = {lava, lava_beat};
LedPatternList random_patterns = {rainbow, confetti, juggle, pacifica, pride};
Expand All @@ -53,7 +54,8 @@ uint8_t pattern_status[6] = {0};
void update_config_callback();
void set_led_patterns(uint8_t);
void next_cycle();
void light_sensor_self_calibration(AsyncWebServerRequest*);
void light_sensor_self_calibration(AsyncWebServerRequest *);
void calibration_procedure();

void setup()
{
Expand Down Expand Up @@ -258,6 +260,12 @@ void loop()
shutdown_delay = 0;
}

if (calibration)
{
calibration_procedure();
calibration = false;
}

tube_driver->loop();
handle_loop();

Expand Down Expand Up @@ -313,12 +321,11 @@ void update_config_callback()
set_led_patterns(cycle);
}

void light_sensor_self_calibration(AsyncWebServerRequest* request)
void calibration_procedure()
{
DEBUG_PRINTLN("Calibrating...");
config.brightness_offset = 0;
config.shutdown_threshold = 0;
send_response(request);
//set offset
tube_driver->turn_off(false);
led_driver->turn_off(false);
Expand All @@ -330,9 +337,17 @@ void light_sensor_self_calibration(AsyncWebServerRequest* request)

tube_driver->turn_on(false);
led_driver->turn_on(false);
tube_driver->set_brightness(MIN_TUBE_BRIGHTNESS);
led_driver->set_brightness(0);
activeDelay(10000);

config.shutdown_threshold = (int)sensor_driver->get_light_sensor_reading() + 5;
DEBUG_PRINT("shutdown_threshold: ");
DEBUG_PRINTLN(config.shutdown_threshold);
}

void light_sensor_self_calibration(AsyncWebServerRequest *request)
{
send_response(request);
calibration = true;
}
1 change: 0 additions & 1 deletion nixie_firmware/src/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ void activeDelay(unsigned long mills)
while (elapsed < mills)
{
delay(0);
system_soft_wdt_feed();
}
}

Expand Down

0 comments on commit 532c52d

Please sign in to comment.