diff --git a/ext/lcd/ui/UI.h b/ext/lcd/ui/UI.h index 67bb972..35c40dd 100644 --- a/ext/lcd/ui/UI.h +++ b/ext/lcd/ui/UI.h @@ -44,9 +44,9 @@ extern Setter setter; static const FontWrap fnt_f1(496,10,f1_data,f1_offsets); #elif UI_FONT == 8 // Comicoro.ttf - static const uint8_t f1_data[] = {80,0,2,0,64,20,0,0,128,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,197,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,2,84,40,206,8,66,34,4,0,128,48,57,142,228,49,31,227,0,0,192,1,128,241,96,30,207,195,19,137,23,16,196,64,112,60,56,30,238,39,10,9,133,66,135,132,4,16,32,0,32,64,128,0,4,1,0,0,0,0,0,0,0,0,0,144,4,4,62,35,5,5,65,31,1,128,200,69,80,36,8,144,20,1,4,2,226,65,18,17,34,65,32,16,9,20,18,172,132,136,68,68,34,1,33,10,9,69,66,184,132,10,32,32,0,32,32,128,16,5,1,0,0,0,0,16,0,0,0,0,144,4,2,148,34,5,2,65,14,1,64,68,65,80,20,4,136,20,1,243,12,18,66,18,9,162,32,16,8,9,20,9,180,140,132,68,66,162,0,33,138,4,41,34,144,136,0,0,230,96,56,115,140,0,68,245,60,78,195,149,187,40,10,37,210,147,4,2,20,199,26,21,65,202,7,64,68,33,140,243,60,132,227,165,0,144,201,36,250,4,161,231,201,251,5,148,8,146,148,130,52,65,18,135,16,138,36,17,36,136,136,0,0,41,17,164,36,210,19,37,45,69,209,36,77,144,40,74,25,17,138,8,2,63,10,166,8,65,0,129,67,68,17,16,2,69,66,132,0,243,76,40,229,11,5,161,32,8,138,4,98,8,130,148,130,14,65,15,136,16,74,180,48,24,132,136,0,128,40,10,162,35,81,20,25,37,69,81,20,133,145,40,105,25,17,145,4,0,10,10,165,8,65,0,33,32,68,9,17,2,69,66,132,36,4,2,168,21,10,5,145,32,8,137,36,226,8,130,162,66,2,33,17,136,16,81,204,72,16,130,144,0,128,44,138,178,32,94,20,25,37,69,209,227,5,146,72,217,36,158,144,4,2,138,7,25,23,65,0,32,40,56,125,14,226,56,130,131,32,0,64,72,19,250,120,15,47,240,136,196,33,243,130,194,60,2,30,161,135,224,48,132,132,16,191,144,0,0,203,113,44,39,80,20,41,37,69,78,0,197,17,199,136,68,208,147,4,0,0,2,0,0,34,0,16,32,0,0,0,0,0,0,0,16,0,0,16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,8,0,0,0,0,0,0,0,128,144,0,0,0,0,0,0,18,0,1,0,0,64,0,1,0,0,0,0,8,144,4,0,0,2,0,0,20,0,0,0,0,0,0,0,0,0,0,0,0,0,224,0,0,0,0,0,0,0,0,0,0,0,0,0,0,48,0,0,0,0,0,0,0,128,193,224,7,0,0,0,0,12,192,0,0,0,64,0,1,0,0,0,0,6,160,2,}; - static const uint16_t f1_offsets[] = {0,1,4,8,15,21,31,38,40,44,48,54,60,63,67,69,73,79,82,88,94,100,106,112,118,124,130,132,135,140,145,150,155,164,171,178,184,191,197,203,211,218,221,228,235,241,249,257,265,272,280,287,293,300,307,314,322,329,336,343,346,350,353,357,364,367,373,379,385,391,396,400,406,412,414,418,424,426,434,440,446,452,458,462,467,471,477,483,490,496,502,507,511,513,}; - static const FontWrap fnt_f1(520,10,f1_data,f1_offsets); +static const uint8_t f1_data[] = {80,0,2,0,64,20,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,176,24,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,68,0,84,40,206,8,66,34,4,0,0,194,16,199,145,60,230,99,28,0,0,56,0,48,30,204,227,121,120,34,241,2,130,24,8,142,7,199,195,253,68,33,161,80,232,144,144,0,2,4,0,4,8,16,128,32,0,0,0,0,0,0,0,0,0,0,146,0,4,62,35,5,5,65,31,1,0,34,153,8,138,4,1,146,34,128,64,64,60,72,34,66,36,8,4,34,129,66,130,149,16,145,136,72,36,32,68,33,161,72,8,151,80,1,4,4,0,4,4,16,162,32,0,0,0,0,0,2,0,0,0,0,146,0,2,148,34,5,2,65,14,1,0,17,17,8,138,130,0,145,34,96,158,65,66,72,34,65,20,4,2,33,129,34,129,150,145,144,72,72,20,32,68,145,32,69,4,18,17,0,192,28,12,103,142,17,128,168,158,199,105,184,114,23,69,161,68,122,146,0,2,20,199,26,21,65,202,7,0,17,17,132,113,158,135,112,188,20,0,50,153,68,159,32,244,60,121,191,128,18,65,146,82,144,38,72,226,16,66,145,36,130,4,17,17,0,32,37,130,148,68,122,162,164,165,40,154,164,9,18,69,41,35,66,17,1,2,63,10,166,8,65,0,1,7,17,17,2,66,160,72,136,16,96,158,9,165,124,161,32,20,4,65,145,64,12,65,144,82,208,33,232,1,17,66,137,22,6,131,16,17,0,16,69,65,116,36,138,34,163,164,40,138,162,48,18,37,45,35,34,146,0,0,10,10,165,8,65,0,33,128,16,17,33,66,160,72,136,144,132,64,0,181,66,161,32,18,4,33,145,68,28,65,80,84,72,32,36,2,17,34,138,25,9,66,16,18,0,144,69,81,22,196,139,34,163,164,40,122,188,64,18,41,155,196,19,146,0,2,138,7,25,23,65,0,32,160,224,144,207,65,28,71,112,16,4,0,8,105,66,31,239,225,5,30,145,56,100,94,80,152,71,192,35,244,16,28,134,144,16,226,23,18,0,96,57,142,229,4,138,34,165,164,200,9,160,56,226,24,145,8,122,146,0,0,0,2,0,0,34,0,16,128,0,0,0,0,0,0,0,0,2,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,16,18,0,0,0,0,0,64,2,32,0,0,0,8,32,0,0,0,0,0,1,146,0,0,0,2,0,0,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,28,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6,0,0,0,0,0,0,0,48,24,252,0,0,0,0,128,1,24,0,0,0,8,32,0,0,0,0,192,0,84,0,}; +static const uint16_t f1_offsets[] = {0,1,4,8,15,21,31,38,40,44,48,54,60,63,69,71,75,81,87,93,99,105,111,117,123,129,135,137,140,145,150,155,160,169,176,183,189,196,202,208,216,223,226,233,240,246,254,262,270,277,285,292,298,305,312,319,327,334,341,348,351,355,358,362,369,372,378,384,390,396,401,405,411,417,419,423,429,431,439,445,451,457,463,467,472,476,482,488,495,501,507,512,516,518,}; +static const FontWrap fnt_f1(528,10,f1_data,f1_offsets); #elif UI_FONT == 9 // Nineteen Ninety Six.otf static const uint8_t f1_data[] = {84,36,8,66,14,99,134,0,0,0,113,48,30,14,36,30,30,62,30,30,0,2,130,7,31,14,30,14,15,30,30,30,33,225,133,8,8,34,194,225,193,225,225,1,39,18,66,64,144,144,143,5,35,0,2,4,0,4,0,64,64,34,8,0,0,0,0,0,0,0,0,0,0,0,41,0,82,36,60,37,17,18,136,32,0,128,136,72,33,17,34,1,1,65,33,33,0,1,68,136,32,17,33,145,16,33,33,33,161,88,132,4,20,85,36,18,34,18,18,242,16,20,36,136,80,80,144,8,82,0,4,4,0,4,48,64,0,32,8,0,0,0,0,0,8,0,0,0,0,128,72,0,82,127,2,22,17,9,232,35,0,128,4,69,64,32,34,1,31,64,33,65,155,248,8,80,166,160,160,128,160,128,128,0,161,128,100,4,164,84,20,20,20,20,20,128,16,20,20,144,72,16,136,8,138,0,96,52,134,229,72,76,35,36,137,77,195,52,76,99,60,81,34,18,9,143,72,0,2,18,60,8,94,8,136,248,240,65,4,65,48,60,17,62,33,32,62,65,64,0,16,72,169,167,159,128,160,143,143,24,159,128,28,4,68,148,20,20,20,20,228,131,16,20,20,17,135,8,70,16,137,0,144,76,73,22,29,210,20,40,73,210,36,77,210,20,8,81,20,36,69,208,200,0,2,18,65,52,33,8,72,33,0,64,4,65,14,64,81,64,65,32,65,126,128,248,8,71,158,184,160,128,160,128,128,160,144,128,100,4,4,148,20,52,20,245,3,132,16,36,18,145,8,7,65,16,1,0,16,69,65,244,9,81,20,232,72,82,20,69,81,224,8,81,148,228,68,140,68,0,0,127,62,82,33,8,36,34,0,32,132,64,65,65,62,65,66,16,65,64,0,1,4,128,128,160,160,160,144,160,128,160,144,68,132,4,5,20,21,210,19,18,17,132,32,66,33,73,8,130,80,32,1,0,144,77,81,22,8,81,84,41,73,82,20,77,89,0,73,153,146,148,68,130,68,0,6,18,8,33,94,48,3,0,6,44,120,32,62,62,16,62,60,8,62,56,27,2,130,1,31,17,31,31,15,159,0,159,32,57,4,249,4,34,226,17,224,21,230,131,192,129,192,70,16,2,207,160,1,254,96,53,142,229,8,94,34,38,82,74,226,52,86,240,48,22,97,19,121,28,37,0,0,0,0,0,0,0,0,0,4,0,0,0,0,0,0,0,0,0,0,0,16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,0,0,0,0,0,4,16,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,8,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,12,0,0,0,0,0,4,16,0,0,0,0,0,48,0,0,0,}; diff --git a/ext/rf/SX1276.h b/ext/rf/SX1276.h index de5df37..cadd369 100644 --- a/ext/rf/SX1276.h +++ b/ext/rf/SX1276.h @@ -456,7 +456,7 @@ public: private: void yield() { - usleep(5000); + usleep(10*1000); // 10 ms. this is the minimum when running with 100 Ticks FreeRTOS } /** diff --git a/ext/sens/INA3221.h b/ext/sens/INA3221.h index f3cb60c..d22e200 100644 --- a/ext/sens/INA3221.h +++ b/ext/sens/INA3221.h @@ -25,9 +25,16 @@ private: public: struct Channel { - int16_t vShunt; - int16_t vBus; + + int16_t vShunt; // in uV * 10(!!!) + int16_t vBus; // in mV + + int getMilliAmps(int shunt_milliOhm) const { + return (vShunt * 10) / shunt_milliOhm; + } + }; + struct Voltages { Channel ch1; Channel ch2; @@ -54,19 +61,19 @@ public: Voltages res; i2c.readReg(ADDR, REG_CH1_VS, sizeof(buf), buf); - res.ch1.vShunt = getVoltage(buf); + res.ch1.vShunt = getShuntVoltage(buf); i2c.readReg(ADDR, REG_CH1_VB, sizeof(buf), buf); - res.ch1.vBus = getVoltage(buf); + res.ch1.vBus = getBusVoltage(buf); i2c.readReg(ADDR, REG_CH2_VS, sizeof(buf), buf); - res.ch2.vShunt = getVoltage(buf); + res.ch2.vShunt = getShuntVoltage(buf); i2c.readReg(ADDR, REG_CH2_VB, sizeof(buf), buf); - res.ch2.vBus = getVoltage(buf); + res.ch2.vBus = getBusVoltage(buf); i2c.readReg(ADDR, REG_CH3_VS, sizeof(buf), buf); - res.ch3.vShunt = getVoltage(buf); + res.ch3.vShunt = getShuntVoltage(buf); i2c.readReg(ADDR, REG_CH3_VB, sizeof(buf), buf); - res.ch3.vBus = getVoltage(buf); + res.ch3.vBus = getBusVoltage(buf); return res; } @@ -77,10 +84,19 @@ public: } private: - + /** convert to bytes into a mV reading */ - int16_t getVoltage(const uint8_t* buf) { - return ((buf[0] << 8) | (buf[1] << 0)); // the lowest 3 bits are always zero. no shift required! + int16_t getBusVoltage(const uint8_t* buf) { + return ((int16_t)(getU16(buf)&0b1111111111111000)); // Bit 0,1,2 are status indicators -> remove, Bit3 = 8mV -> (LSB = 1mV) + } + + /** convert to bytes into a uV reading */ + int16_t getShuntVoltage(const uint8_t* buf) { + return ((int16_t)(getU16(buf)&0b1111111111111000))/2; // Bit 0,1,2 are status indicators -> remove, Bit3 = 40 uV -> / 2 and result is in 10 uV + } + + uint16_t getU16(const uint8_t* buf) { + return ((buf[0] << 8) | (buf[1] << 0)); } };