Compare commits

..

No commits in common. "f40e05bb564cd8681186de482699c7e725abf6ac" and "208ee058fc4033c742af7f433d5496bbe2fa5043" have entirely different histories.

2 changed files with 28 additions and 110 deletions

View file

@ -154,12 +154,11 @@ void QSPI_74HC595_4X_DISPLAYComponent::display()
const uint8_t *buf_ptr = reinterpret_cast<const uint8_t *>(this->buffer_); const uint8_t *buf_ptr = reinterpret_cast<const uint8_t *>(this->buffer_);
for (uint8_t i = 0; i < 8; i++) for (uint8_t i = 0; i < 8; i++)
{ {
uint32_t start = micros();
this->enable(); this->enable();
this->write_cmd_addr_data(0, 0, 0, 0, buf_ptr, 8, 4); this->write_cmd_addr_data(0, 0, 0, 0, buf_ptr, 8, 4);
buf_ptr += 8; buf_ptr += 8;
this->disable(); this->disable();
delay_microseconds_safe(delay - (micros() - start)); delay_microseconds_safe(delay);
} }
// zero out everything to have a somewhat uniform duty cycle for all digits // zero out everything to have a somewhat uniform duty cycle for all digits
this->enable(); this->enable();

View file

@ -44,6 +44,17 @@ time:
- platform: sntp - platform: sntp
id: sntp_time id: sntp_time
timezone: Europe/Berlin timezone: Europe/Berlin
on_time:
- seconds: /10
then:
- logger.log:
level: INFO
format: "%02d:%02d:%02d.%02d"
args:
- 'uint32_t(id(runtime).state/3600) - uint32_t(id(runtime).state/86400)*1440'
- 'uint32_t(id(runtime).state/60) - uint32_t(id(runtime).state/3600)*60'
- 'uint32_t(id(runtime).state) - uint32_t(id(runtime).state/60)*60'
- 'uint32_t((id(runtime).state - uint32_t(id(runtime).state))*25)'
spi: spi:
- id: quad_spi_bus - id: quad_spi_bus
@ -60,84 +71,6 @@ sensor:
id: runtime id: runtime
update_interval: 100ms update_interval: 100ms
globals:
- id: countdown_end
type: time_t
- id: uptime_start
type: time_t
number:
- platform: template
name: "Countdown set H"
id: cd_set_h
initial_value: 0
min_value: 0
max_value: 99
step: 1
optimistic: true
mode: box
- platform: template
name: "Countdown set M"
id: cd_set_m
initial_value: 0
min_value: 0
max_value: 59
step: 1
optimistic: true
mode: box
- platform: template
name: "Countdown set S"
id: cd_set_s
initial_value: 0
min_value: 0
max_value: 59
step: 1
optimistic: true
mode: box
button:
- platform: template
name: "Countdown set"
on_press:
- lambda: |-
id(countdown_end) =
id(sntp_time).timestamp_now()
+ uint32_t(id(cd_set_h).state)*3600
+ uint32_t(id(cd_set_m).state)*60
+ uint32_t(id(cd_set_s).state);
- platform: template
name: "Countdown Minutes 1m"
on_press:
- lambda: |-
id(countdown_end) = id(sntp_time).timestamp_now() + 60;
- platform: template
name: "Countdown Minutes 5m"
on_press:
- lambda: |-
id(countdown_end) = id(sntp_time).timestamp_now() + 300;
- platform: template
name: "Countdown Minutes 10m"
on_press:
- lambda: |-
id(countdown_end) = id(sntp_time).timestamp_now() + 600;
- platform: template
name: "Countdown Hours 1h"
on_press:
- lambda: |-
id(countdown_end) = id(sntp_time).timestamp_now() + 3600;
- platform: template
name: "Countdown Hours 2h"
on_press:
- lambda: |-
id(countdown_end) = id(sntp_time).timestamp_now() + 7200;
- platform: template
name: "Runtime Reset"
on_press:
- lambda: |-
id(uptime_start) = id(runtime).state;
display: display:
- platform: qspi_74hc595_4x_display - platform: qspi_74hc595_4x_display
cs_pin: GPIO5 cs_pin: GPIO5
@ -145,46 +78,32 @@ display:
update_interval: 10ms update_interval: 10ms
spi_id: quad_spi_bus spi_id: quad_spi_bus
lambda: |- lambda: |-
static uint32_t last_micros=0;
static uint32_t clock_frames=0; static uint32_t clock_frames=0;
static uint32_t old_clock=0; static uint32_t old_clock=0;
if(id(sntp_time).now().second!=old_clock){ if(id(sntp_time).now().second!=old_clock){
last_micros = micros(); clock_frames=0;
old_clock=id(sntp_time).now().second; old_clock=id(sntp_time).now().second;
} else { } else {
clock_frames = (micros()-last_micros)/10000; clock_frames++;
} }
/////////// first display //it.printf(0, ".*`,_+'-");
it.printf(0, ".*`,_+'-"); //it.printf(0, "88888888");
it.strftime(0, "%H%M%S", id(sntp_time).now());
it.printf(6, "%02d", clock_frames%100);
/////////// second display //it.strftime(8, "%H%M%S", id(sntp_time).now());
it.strftime(8, "%H%M%S", id(sntp_time).now()); //it.printf(14, "%2d", clock_frames);
it.printf(14, "%02d", clock_frames%100); /*it.strftime(8, "%H%M%S", id(sntp_time).now());*/
/*it.printf(14, "%1d", 0)*/
/////////// third display /*it.printf(16, "%02d%02d%02d%02d",
{ uint32_t(id(runtime).state/3600) - uint32_t(id(runtime).state/86400)*1440,
double delta = id(runtime).state - id(uptime_start); uint32_t(id(runtime).state/60) - uint32_t(id(runtime).state/3600)*60,
uint32_t hours = delta/3600; uint32_t(id(runtime).state) - uint32_t(id(runtime).state/60)*60,
delta -= hours*3600; uint32_t((id(runtime).state - uint32_t(id(runtime).state))*25) );
uint32_t minutes = delta/60; */
delta -= minutes*60;
uint32_t seconds = delta;
uint32_t frames = (100*delta) - (100*seconds);
it.printf(16, "%02d%02d%02d%02d", hours, minutes, seconds, frames);
}
/////////// fourth display
if (id(countdown_end) > id(sntp_time).timestamp_now()) {
time_t delta=difftime(id(countdown_end), id(sntp_time).timestamp_now());
time_t hours = delta/3600;
delta -= hours*3600;
time_t minutes = (delta)/60;
delta -= minutes*60;
time_t seconds = delta;
it.printf(24, "%02ld%02ld%02ld%02d", hours, minutes, seconds, (99-clock_frames%100));
}
# the first display should display a test string to figure out the digit and segment map: # the first display should display a test string to figure out the digit and segment map:
# digit 0: >.< character (dot segment on) # digit 0: >.< character (dot segment on)