|
@@ -9,6 +9,7 @@
|
|
|
#include "ssd1306xled/font8x16.h"
|
|
|
#include "ssd1306xled/ssd1306xled.h"
|
|
|
#include "ssd1306xled/ssd1306xledtx.h"
|
|
|
+#include "tinyavrlib/num2str.h"
|
|
|
|
|
|
/* Defines */
|
|
|
|
|
@@ -39,43 +40,73 @@ int main(void) {
|
|
|
ssd1306_init();
|
|
|
|
|
|
/* Clear flags */
|
|
|
- Flag.newTempSet = 0;
|
|
|
+ Flag.newTempSet = 1;
|
|
|
Flag.AHT10state = 0;
|
|
|
|
|
|
/* Set tasks */
|
|
|
- RTOS_SetTask(checkTemperatureSetpoint, 10, 100);
|
|
|
+ RTOS_SetTask(checkTemperatureSetpoint, 5, 50);
|
|
|
RTOS_SetTask(sensorStart, 50, 1000);
|
|
|
- RTOS_SetTask(sensorGetData, 1050, 1000);
|
|
|
+ RTOS_SetTask(sensorGetData, 800, 1000);
|
|
|
RTOS_SetTask(LedOn, 1, 1000);
|
|
|
+ RTOS_SetTask(LedOff, 201, 1000);
|
|
|
|
|
|
// ssd1306_fill2(0xff, 0x00);
|
|
|
ssd1306_clear();
|
|
|
- ssd1306tx_init(ssd1306xled_font6x8data, 0);
|
|
|
+// ssd1306tx_init(ssd1306xled_font6x8data, 0);
|
|
|
// ssd1306xled_font8x16data
|
|
|
ssd1306tx_stringxy((uint8_t const *)ssd1306xled_font8x16data, 0, 0, "Hello, World! :)");
|
|
|
- ssd1306_setpos(0, 3);
|
|
|
- ssd1306tx_string("SSD1306xLED Library");
|
|
|
+// ssd1306_setpos(0, 3);
|
|
|
+// ssd1306tx_string("SSD1306xLED Library");
|
|
|
// ssd1306_setpos(0, 3);
|
|
|
// ssd1306tx_string("!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[5]^_`");
|
|
|
- ssd1306tx_stringxy((uint8_t const *)ssd1306xled_font8x16data, 0, 5, "TINUSAUR Project");
|
|
|
- ssd1306_setpos(0, 7);
|
|
|
- ssd1306tx_string("http://tinusaur.org");
|
|
|
- tdelay_ms(2000);
|
|
|
+// ssd1306tx_stringxy((uint8_t const *)ssd1306xled_font8x16data, 0, 5, "TINUSAUR Project");
|
|
|
+// ssd1306_setpos(0, 7);
|
|
|
+// ssd1306tx_string("http://tinusaur.org");
|
|
|
+ tdelay_ms(1000);
|
|
|
+
|
|
|
ssd1306_clear();
|
|
|
+ ssd1306tx_stringxy((uint8_t const *)ssd1306xled_font8x16data, 1, 0, "Set:");
|
|
|
+ ssd1306tx_stringxy((uint8_t const *)ssd1306xled_font8x16data, 1, 3, " T:");
|
|
|
+ ssd1306tx_stringxy((uint8_t const *)ssd1306xled_font8x16data, 1, 5, " H:");
|
|
|
+ char buffer[6] = {'\0'};
|
|
|
+ uint8_t digits = 0;
|
|
|
|
|
|
/* Infinity loop */
|
|
|
do {
|
|
|
+
|
|
|
if (Flag.newTempSet != 0) {
|
|
|
Flag.newTempSet = 0;
|
|
|
- ssd1306_setpos(1, 5);
|
|
|
+ /*
|
|
|
+ ssd1306_setpos(25, 0);
|
|
|
ssd1306tx_numdec(TemperatureSetpoint);
|
|
|
+ ssd1306tx_string(" C");
|
|
|
+ */
|
|
|
+ if (TemperatureSetpoint != 0) {
|
|
|
+ digits = usint2decascii(TemperatureSetpoint, buffer);
|
|
|
+ ssd1306tx_stringxy((uint8_t const *)ssd1306xled_font8x16data, 40, 0, buffer+digits);
|
|
|
+ ssd1306tx_stringxy((uint8_t const *)ssd1306xled_font8x16data, 56, 0, " C ");
|
|
|
+ } else {
|
|
|
+ ssd1306tx_stringxy((uint8_t const *)ssd1306xled_font8x16data, 40, 0, " Off");
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- ssd1306_setpos(1, 3);
|
|
|
+ //ssd1306_setpos(13, 3);
|
|
|
if (Flag.AHT10state == 0) {
|
|
|
+ /*
|
|
|
ssd1306tx_numdec(Sensor.Temperature);
|
|
|
+ ssd1306tx_string(" C");
|
|
|
+ ssd1306_setpos(13, 5);
|
|
|
+ ssd1306tx_numdec(Sensor.Humidity);
|
|
|
+ ssd1306tx_string(" P");
|
|
|
+ */
|
|
|
+ digits = usint2decascii((int8_t)Sensor.Temperature, buffer);
|
|
|
+ ssd1306tx_stringxy((uint8_t const *)ssd1306xled_font8x16data, 40, 3, buffer+digits);
|
|
|
+ digits = usint2decascii(Sensor.Humidity, buffer);
|
|
|
+ ssd1306tx_stringxy((uint8_t const *)ssd1306xled_font8x16data, 40, 5, buffer+digits);
|
|
|
} else {
|
|
|
- ssd1306tx_string("AHT10 error");
|
|
|
+ //ssd1306tx_string("AHT10 error");
|
|
|
+ ssd1306tx_stringxy((uint8_t const *)ssd1306xled_font8x16data, 40, 3, "Error");
|
|
|
+ ssd1306tx_stringxy((uint8_t const *)ssd1306xled_font8x16data, 40, 5, " ");
|
|
|
}
|
|
|
|
|
|
RTOS_DispatchTask();
|
|
@@ -106,8 +137,8 @@ static void board_Init(void) {
|
|
|
DDRB = 0x22; // PB1 - Triac control, PB5 - Green LED
|
|
|
DDRC = 0x30; // I2C output
|
|
|
PORTB = 0x03; // close Triac, enable pull-up for D8
|
|
|
- PORTC = 0x3e; // I2C = 1, enable pull-up for switch
|
|
|
- PORTD = 0xfc; // enable pull-up for D0-D7 (Switch)
|
|
|
+ PORTC = 0x3e; // I2C = 1
|
|
|
+ PORTD = 0xff; // enable pull-up for D0-D7 (Switch)
|
|
|
|
|
|
/* Timer0 - RTOS & tdelay_ms() */
|
|
|
TCCR0B = ((0<<CS02)|(1<<CS01)|(1<<CS00));
|
|
@@ -160,7 +191,7 @@ static void checkTemperatureSetpoint(void) {
|
|
|
TemperatureSetpoint = 0;
|
|
|
}
|
|
|
} else {
|
|
|
- pvalue = ~(PINB) | (1<<PB0);
|
|
|
+ pvalue = (~(PINB)) & (1<<PB0);
|
|
|
if (pvalue != 0) {
|
|
|
TemperatureSetpoint = 90;
|
|
|
} else {
|
|
@@ -200,7 +231,6 @@ static void sensorGetData(void) {
|
|
|
|
|
|
static void LedOn(void) {
|
|
|
PORTB |= (1<<PB5);
|
|
|
- RTOS_SetTask(LedOff, 200, 0);
|
|
|
}
|
|
|
|
|
|
static void LedOff(void) {
|