Compare commits

...

2 Commits

Author SHA1 Message Date
Martin Brodbeck 80fb3c8cb5 additional sleep logic removed 2022-06-02 09:56:45 +02:00
Martin Brodbeck 7f6873284c bi_decl added
(but not sure why)
2022-06-02 09:56:15 +02:00
2 changed files with 9 additions and 12 deletions

View File

@ -31,10 +31,11 @@ absolute_time_t lastPressed = get_absolute_time();
using std::string;
void buttonPressedCallback(uint gpio, uint32_t events) {
if (absolute_time_diff_us(lastPressed, get_absolute_time()) < 750000) {
absolute_time_t now = get_absolute_time();
if (absolute_time_diff_us(lastPressed, now) < 750000) {
return;
} else {
lastPressed = get_absolute_time();
lastPressed = now;
}
switch (gpio) {
@ -88,7 +89,6 @@ int main() {
sleep_ms(3000);
while (true) {
absolute_time_t start = get_absolute_time();
oneWire.convert_temperature(address, true, false);
temp_act = oneWire.temperature(address);
@ -99,6 +99,7 @@ int main() {
} else if (!isSystemOn) {
isHeating = false;
}
isHeating ? heatInfo = ">H<" : heatInfo = " ";
isSystemOn ? systemInfo = "ON " : systemInfo = "OFF";
@ -113,13 +114,5 @@ int main() {
myLCD.setCursor(0, 0);
myLCD.sendString(lcdText.str());
absolute_time_t stop = get_absolute_time();
int64_t duration_ms = absolute_time_diff_us(start, stop) / 1000;
int64_t timeToSleep = 1000 - duration_ms;
if (timeToSleep > 0)
sleep_ms(timeToSleep);
}
}

View File

@ -1,3 +1,5 @@
#include "pico/binary_info.h"
#include "lcd.h"
// commands
@ -30,11 +32,13 @@ constexpr int LCD_ENABLE_BIT = 0x04;
LCD::LCD(i2c_inst_t *i2c, const uint gpio_sda, const uint gpio_scl,
const uint8_t i2c_addr, uint8_t num_cols, uint8_t num_lines)
: i2c{i2c}, i2c_addr{i2c_addr}, num_cols{num_cols}, num_lines{num_lines} {
i2c_init(i2c1, 100 * 1000);
i2c_init(i2c, 100 * 1000);
gpio_set_function(gpio_sda, GPIO_FUNC_I2C);
gpio_set_function(gpio_scl, GPIO_FUNC_I2C);
gpio_pull_up(gpio_sda);
gpio_pull_up(gpio_scl);
// Make the I2C pins available to picotool
bi_decl(bi_2pins_with_func(gpio_sda, gpio_scl, GPIO_FUNC_I2C));
sendByte(0x03, Mode::COMMAND);
sendByte(0x03, Mode::COMMAND);