kris83

Elektryczny rower Smart

Jul 5th, 2021 (edited)
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 17.03 KB | None | 0 0
  1. /* Arduino-DEM jako licznik rowerowy
  2.   Rysowanie bitmapy skali
  3.    FreqCount - Example with serial output
  4.    http://www.pjrc.com/teensy/td_libs_FreqCount.html
  5.  
  6.   LCD --- Arduino KS108
  7.  
  8.   1  VSS  -  GND
  9.   2  VDD  -  +5V   ---   POT 1
  10.   3   V0  -  ---   ---   POT 2
  11.   4   RS  -  A1
  12.   5   RW  -  A2
  13.   6   E   -  A3
  14.   7  DB0  -  D4
  15.   8  DB1  -  D5
  16.   9  DB2  -  D6
  17.   10 DB3  -  D7
  18.   11 DB4  -  D8
  19.   12 DB5  -  D9
  20.   13 DB6  -  D10
  21.   14 DB7  -  D11
  22.   15 CS1  -  D12
  23.   16 RES  -  NIE PODLACZAC
  24.   17 CS2  -  D13
  25.   18 CS3  -  A0
  26.   19 VEE  -  ---   ---   POT 3
  27.   20 LED  -  +5V Podswietlenie
  28.  
  29. */
  30.  
  31. #include <Arduino.h>
  32. #include <U8g2lib.h>
  33. #include <EEPROM.h>
  34. #ifdef U8X8_HAVE_HW_SPI
  35. #include <SPI.h>
  36. #endif
  37. #ifdef U8X8_HAVE_HW_I2C
  38. #include <Wire.h>
  39. #endif
  40.  
  41. //U8G2_SSD1306_128X32_WINSTAR_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE, /* clock=*/ SCL, /* data=*/ SDA);   // pin remapping with ESP8266 HW I2C
  42. //U8G2_KS0108_128X64_1 u8g2(U8G2_R0, 21, 22, 23, 24, 25, 26, 27, 28, /*enable=*/ 20, /*dc=*/ 18, /*cs0=*/ 29, /*cs1=*/ 30, /*cs2=*/ U8X8_PIN_NONE, /* reset=*/  U8X8_PIN_NONE);   // Set R/W to low!
  43. U8G2_KS0108_ERM19264_1 u8g2(U8G2_R0, 21, 22, 23, 24, 25, 26, 27, 28, /*enable=*/ 20, /*dc=*/ 18, /*cs0=*/ 29, /*cs1=*/ 30, /*cs2=*/ 31, /* reset=*/  U8X8_PIN_NONE);  // Set R/W to low!
  44. //U8G2_T6963_240X128_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable/wr=*/ 17, /*cs/ce=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND
  45. //U8G2_T6963_256X64_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable/wr=*/ 17, /*cs/ce=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND
  46. //U8G2_T6963_160X80_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable/wr=*/ 17, /*cs/ce=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND
  47. //U8G2_T6963_128X64_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable/wr=*/ 17, /*cs/ce=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND
  48. //U8G2_T6963_128X64_ALT_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable/wr=*/ 17, /*cs/ce=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND
  49.  
  50. //=================================================
  51. #include <OneWire.h>        //Temperatura zewnetrzna
  52. #include <DallasTemperature.h>
  53. #define ONE_WIRE_BUS 6
  54. OneWire oneWire(ONE_WIRE_BUS);
  55. DallasTemperature sensors(&oneWire);
  56. // Adresy DS18B20
  57. uint8_t sensor1[8] = { 0x28, 0x90, 0x4E, 0x8A, 0x02, 0x00, 0x00, 0x69 }; //zewnetrzna
  58. //=================================================
  59.  
  60. int lcd_gnd_RS = 18;
  61. int lcd_gnd_RW = 19;
  62.  
  63. int Wejscie_LED_pozycyjne = 5;
  64. int Wyjscie_LED_pozycyjne = 34;
  65.  
  66. int Wejscie_LED_pozycyjne_2 = 5;
  67. int Wyjscie_LED_pozycyjne_2 = 36;
  68.  
  69. int Wejscie_LED_STOP = 4;
  70. int Wyjscie_LED_STOP = 40;
  71.  
  72. int Wejscie_Migacz_Lewy = 9;
  73. int Wyjscie_Migacz_Lewy =  42;
  74.  
  75. int Wejscie_Migacz_Prawy = 0;
  76. int Wyjscie_Migacz_Prawy =  44;
  77.  
  78. int Wejscie_Stacyjka = 0;
  79. int Wyjscie_Stacyjka = 46;
  80.  
  81. int Podswietlenie_PWM = 12;
  82. int Wyjscie_Alarm = 13;
  83.  
  84. int Wejscie_Klawisz_Menu = 5;
  85. int Pomiar_Predkosci = 3;                                        //pomiar predkosci z kola
  86.  
  87. unsigned long aktualnyCzas = 0;
  88.  
  89. unsigned long zapamietanyCzas_Migacz_Lewy = 0;
  90. int stan_Migacz_Lewy = LOW;
  91. unsigned long zapamietanyCzas_Migacz_Prawy = 0;
  92. int stan_Migacz_Prawy = LOW;
  93.  
  94. int stateButton_Klawisz_Menu;
  95. int stateRelay_Klawisz_Menu = LOW;
  96.  
  97. int previous_Klawisz_Menu = LOW;
  98. long time = 0;
  99. long debounce_Klawisz_Menu = 500;
  100.  
  101. //=================================================
  102. boolean Strona_1 = false;
  103. boolean Strona_2 = false;
  104. //=================================================
  105.  
  106. #define Suma_napiec Cela_1_in + Cela_2_in + Cela_3_in + Cela_4_in + Cela_5_in + Cela_6_in + Cela_7_in + Cela_8_in + Cela_9_in
  107. //#define Suma_napiec Cela_1_in + Cela_2_in + Cela_3_in + Cela_4_in + Cela_5_in + Cela_6_in + Cela_7_in + Cela_8_in + Cela_9_in + Cela_9_in + Cela_10_in + Cela_11_in + Cela_12_in + Cela_13_in + Cela_14_in + Cela_15_in + Cela_16_in
  108.  
  109. //=================================================
  110.  
  111. // RemoteXY select connection mode and include library
  112. #define REMOTEXY_MODE__ESP8266_HARDSERIAL_POINT
  113.  
  114. #include <RemoteXY.h>
  115.  
  116. // RemoteXY connection settings
  117. #define REMOTEXY_SERIAL Serial3
  118. #define REMOTEXY_SERIAL_SPEED 115200
  119. #define REMOTEXY_WIFI_SSID "Electrik Bike"
  120. #define REMOTEXY_WIFI_PASSWORD "Krzysiek19835"
  121. #define REMOTEXY_SERVER_PORT 6377
  122.  
  123. // RemoteXY configurate
  124. #pragma pack(push, 1)
  125. uint8_t RemoteXY_CONF[] =
  126. { 255, 9, 0, 55, 0, 239, 1, 11, 24, 1,
  127.   2, 1, 38, 42, 15, 5, 24, 24, 135, 37,
  128.   79, 78, 0, 79, 70, 70, 0, 2, 1, 38,
  129.   47, 15, 5, 24, 24, 135, 37, 79, 78, 0,
  130.   79, 70, 70, 0, 2, 1, 38, 64, 15, 5,
  131.   24, 24, 135, 37, 79, 78, 0, 79, 70, 70,
  132.   0, 129, 0, 16, 43, 12, 3, 16, 83, 116,
  133.   97, 99, 121, 106, 107, 97, 0, 129, 0, 14,
  134.   48, 17, 3, 16, 79, 197, 155, 119, 105, 101,
  135.   116, 108, 101, 110, 105, 101, 0, 129, 0, 18,
  136.   65, 9, 3, 16, 65, 108, 97, 114, 109, 0,
  137.   129, 0, 12, 11, 3, 2, 16, 48, 37, 0,
  138.   129, 0, 48, 11, 5, 2, 16, 49, 48, 48,
  139.   37, 0, 129, 0, 22, 11, 4, 2, 16, 50,
  140.   53, 37, 0, 129, 0, 30, 11, 4, 2, 16,
  141.   53, 48, 37, 0, 129, 0, 38, 11, 4, 2,
  142.   16, 55, 53, 37, 0, 129, 0, 23, 2, 17,
  143.   5, 16, 66, 97, 116, 101, 114, 105, 97, 0,
  144.   1, 0, 36, 79, 9, 9, 64, 31, 226, 134,
  145.   144, 0, 1, 0, 46, 79, 9, 9, 64, 31,
  146.   226, 134, 146, 0, 129, 0, 11, 82, 24, 3,
  147.   16, 75, 105, 101, 114, 117, 110, 107, 111, 119,
  148.   115, 107, 97, 122, 121, 0, 129, 0, 2, 30,
  149.   29, 3, 16, 84, 101, 109, 112, 101, 114, 97,
  150.   116, 117, 114, 97, 32, 115, 105, 108, 110, 105,
  151.   107, 97, 58, 0, 129, 0, 15, 34, 8, 3,
  152.   16, 83, 116, 97, 110, 58, 0, 67, 0, 32,
  153.   29, 15, 5, 16, 26, 16, 67, 0, 32, 33,
  154.   30, 4, 16, 26, 26, 129, 0, 42, 29, 4,
  155.   4, 16, 194, 176, 67, 0, 2, 1, 38, 69,
  156.   15, 5, 24, 24, 135, 37, 79, 78, 0, 79,
  157.   70, 70, 0, 129, 0, 9, 70, 28, 3, 16,
  158.   79, 103, 114, 97, 110, 105, 99, 122, 101, 110,
  159.   105, 101, 32, 109, 111, 99, 121, 0, 65, 28,
  160.   12, 7, 3, 3, 65, 28, 16, 7, 3, 3,
  161.   65, 28, 20, 7, 3, 3, 65, 30, 24, 7,
  162.   3, 3, 65, 30, 28, 7, 3, 3, 65, 30,
  163.   32, 7, 3, 3, 65, 26, 36, 7, 3, 3,
  164.   65, 26, 40, 7, 3, 3, 65, 26, 44, 7,
  165.   3, 3, 65, 26, 48, 7, 3, 3, 2, 1,
  166.   38, 52, 15, 5, 24, 24, 135, 37, 79, 78,
  167.   0, 79, 70, 70, 0, 129, 0, 13, 53, 19,
  168.   3, 16, 79, 197, 155, 119, 105, 101, 116, 108,
  169.   101, 110, 105, 101, 32, 50, 0, 1, 0, 41,
  170.   90, 9, 9, 64, 31, 226, 153, 171, 0, 129,
  171.   0, 14, 94, 18, 3, 16, 79, 100, 115, 116,
  172.   114, 97, 115, 122, 97, 99, 122, 0, 1, 0,
  173.   43, 57, 6, 6, 1, 31, 83, 84, 79, 80,
  174.   0, 129, 0, 13, 59, 19, 3, 16, 197, 154,
  175.   119, 105, 97, 116, 108, 111, 32, 83, 84, 79,
  176.   80, 0
  177. };
  178.  
  179. // this structure defines all the variables and events of your control interface
  180. struct {
  181.  
  182.   // input variables
  183.   uint8_t switch_stacyjka; // =1 if switch ON and =0 if OFF
  184.   uint8_t switch_swiatla; // =1 if switch ON and =0 if OFF
  185.   uint8_t switch_alarm; // =1 if switch ON and =0 if OFF
  186.   uint8_t button_migacz_lewy; // =1 if button pressed, else =0
  187.   uint8_t button_migacz_prawy; // =1 if button pressed, else =0
  188.   uint8_t switch_ograniczenie; // =1 if switch ON and =0 if OFF
  189.   uint8_t switch_swiatla_2; // =1 if switch ON and =0 if OFF
  190.   uint8_t button_migacz_odstraszacz; // =1 if button pressed, else =0
  191.   uint8_t button_STOP; // =1 if button pressed, else =0
  192.  
  193.   // output variables
  194.   char text_temperatura[16];  // string UTF8 end zero
  195.   char text_stan[26];  // string UTF8 end zero
  196.   uint8_t led_0_r; // =0..255 LED Red brightness
  197.   uint8_t led_1_r; // =0..255 LED Red brightness
  198.   uint8_t led_2_r; // =0..255 LED Red brightness
  199.   uint8_t led_3_r; // =0..255 LED Red brightness
  200.   uint8_t led_3_g; // =0..255 LED Green brightness
  201.   uint8_t led_4_r; // =0..255 LED Red brightness
  202.   uint8_t led_4_g; // =0..255 LED Green brightness
  203.   uint8_t led_5_r; // =0..255 LED Red brightness
  204.   uint8_t led_5_g; // =0..255 LED Green brightness
  205.   uint8_t led_6_g; // =0..255 LED Green brightness
  206.   uint8_t led_7_g; // =0..255 LED Green brightness
  207.   uint8_t led_8_g; // =0..255 LED Green brightness
  208.   uint8_t led_9_g; // =0..255 LED Green brightness
  209.  
  210.   // other variable
  211.   uint8_t connect_flag;  // =1 if wire connected, else =0
  212.  
  213. } RemoteXY;
  214. #pragma pack(pop)
  215.  
  216. //=================================================
  217.  
  218. //Zmienne do pomiaru prędkości
  219. int count, count1;
  220. char m_str[6];
  221. String m1_str;
  222. unsigned long duration;
  223. float r_kola = 0.7;                                               //promień koła w metrach
  224. float d_kola;
  225.  
  226. //zmienne do obliczenia długosci drogi
  227. int lok;                                                          //liczba obrotów koła
  228. float d_etapu, de_km;                                             //długość etapu, odległość w km
  229. int d_total;                                                      //odległość całkowita od początku
  230. char d_tot_str[6];
  231. int de_int,  de_int1, de_dz;
  232. char de_str[3], de1_str[3];
  233.  
  234. //zmienne do pomiaru czasu
  235. byte godz, minuty, sekundy;
  236. unsigned long czas_e;                                             //całkowity czas etapu
  237. char godz_str[3], minuty_str[3], sekundy_str[3];
  238.  
  239. //zmienne do pomiaru napiecia
  240. //================================= CELA_1
  241. float Cela_1_out = 0.0;
  242. float Cela_1_in = 0.0;
  243. float R1_Cela_1 = 100000.0; // resistance of R1 (100K)
  244. float R2_Cela_1 = 10000.0; // resistance of R2 (10K)
  245. int value_1 = 0;
  246. //================================= CELA_2
  247. float Cela_2_out = 0.0;
  248. float Cela_2_in = 0.0;
  249. float R1_Cela_2 = 100000.0; // resistance of R1 (100K)
  250. float R2_Cela_2 = 10000.0; // resistance of R2 (10K)
  251. int value_2 = 0;
  252. //================================= CELA_3
  253. float Cela_3_out = 0.0;
  254. float Cela_3_in = 0.0;
  255. float R1_Cela_3 = 100000.0; // resistance of R1 (100K)
  256. float R2_Cela_3 = 10000.0; // resistance of R2 (10K)
  257. int value_3 = 0;
  258. //================================= CELA_4
  259. float Cela_4_out = 0.0;
  260. float Cela_4_in = 0.0;
  261. float R1_Cela_4 = 100000.0; // resistance of R1 (100K)
  262. float R2_Cela_4 = 10000.0; // resistance of R2 (10K)
  263. int value_4 = 0;
  264. //================================= CELA_5
  265. float Cela_5_out = 0.0;
  266. float Cela_5_in = 0.0;
  267. float R1_Cela_5 = 100000.0; // resistance of R1 (100K)
  268. float R2_Cela_5 = 10000.0; // resistance of R2 (10K)
  269. int value_5 = 0;
  270. //================================= CELA_6
  271. float Cela_6_out = 0.0;
  272. float Cela_6_in = 0.0;
  273. float R1_Cela_6 = 100000.0; // resistance of R1 (100K)
  274. float R2_Cela_6 = 10000.0; // resistance of R2 (10K)
  275. int value_6 = 0;
  276. //================================= CELA_7
  277. float Cela_7_out = 0.0;
  278. float Cela_7_in = 0.0;
  279. float R1_Cela_7 = 100000.0; // resistance of R1 (100K)
  280. float R2_Cela_7 = 10000.0; // resistance of R2 (10K)
  281. int value_7 = 0;
  282. //================================= CELA_8
  283. float Cela_8_out = 0.0;
  284. float Cela_8_in = 0.0;
  285. float R1_Cela_8 = 100000.0; // resistance of R1 (100K)
  286. float R2_Cela_8 = 10000.0; // resistance of R2 (10K)
  287. int value_8 = 0;
  288. //================================= CELA_9
  289. float Cela_9_out = 0.0;
  290. float Cela_9_in = 0.0;
  291. float R1_Cela_9 = 100000.0; // resistance of R1 (100K)
  292. float R2_Cela_9 = 10000.0; // resistance of R2 (10K)
  293. int value_9 = 0;
  294. //================================= CELA_10
  295. float Cela_10_out = 0.0;
  296. float Cela_10_in = 0.0;
  297. float R1_Cela_10 = 100000.0; // resistance of R1 (100K)
  298. float R2_Cela_10 = 10000.0; // resistance of R2 (10K)
  299. int value_10 = 0;
  300. //================================= CELA_11
  301. float Cela_11_out = 0.0;
  302. float Cela_11_in = 0.0;
  303. float R1_Cela_11 = 100000.0; // resistance of R1 (100K)
  304. float R2_Cela_11 = 10000.0; // resistance of R2 (10K)
  305. int value_11 = 0;
  306. //================================= CELA_12
  307. float Cela_12_out = 0.0;
  308. float Cela_12_in = 0.0;
  309. float R1_Cela_12 = 100000.0; // resistance of R1 (100K)
  310. float R2_Cela_12 = 10000.0; // resistance of R2 (10K)
  311. int value_12 = 0;
  312. //================================= CELA_13
  313. float Cela_13_out = 0.0;
  314. float Cela_13_in = 0.0;
  315. float R1_Cela_13 = 100000.0; // resistance of R1 (100K)
  316. float R2_Cela_13 = 10000.0; // resistance of R2 (10K)
  317. int value_13 = 0;
  318. //================================= CELA_14
  319. float Cela_14_out = 0.0;
  320. float Cela_14_in = 0.0;
  321. float R1_Cela_14 = 100000.0; // resistance of R1 (100K)
  322. float R2_Cela_14 = 10000.0; // resistance of R2 (10K)
  323. int value_14 = 0;
  324. //================================= CELA_14
  325. float Cela_15_out = 0.0;
  326. float Cela_15_in = 0.0;
  327. float R1_Cela_15 = 100000.0; // resistance of R1 (100K)
  328. float R2_Cela_15 = 10000.0; // resistance of R2 (10K)
  329. int value_15 = 0;
  330. //================================= CELA_14
  331. float Cela_16_out = 0.0;
  332. float Cela_16_in = 0.0;
  333. float R1_Cela_16 = 100000.0; // resistance of R1 (100K)
  334. float R2_Cela_16 = 10000.0; // resistance of R2 (10K)
  335. int value_16 = 0;
  336.  
  337. void setup(void) {
  338.   Serial.begin(9600);
  339.  
  340.   RemoteXY_Init ();
  341.  
  342.   pinMode(Wejscie_LED_pozycyjne, INPUT_PULLUP);
  343.   pinMode(Wejscie_LED_pozycyjne_2, INPUT_PULLUP);
  344.   pinMode(Wejscie_LED_STOP, INPUT_PULLUP);
  345.   pinMode(Wejscie_Migacz_Lewy, INPUT_PULLUP);
  346.   pinMode(Wejscie_Migacz_Prawy, INPUT_PULLUP);
  347.   pinMode(Wejscie_Stacyjka, INPUT_PULLUP);
  348.   pinMode(Wejscie_Klawisz_Menu, INPUT_PULLUP);
  349.  
  350.   pinMode(Wyjscie_LED_pozycyjne, OUTPUT);
  351.   pinMode(Wyjscie_LED_pozycyjne_2, OUTPUT);
  352.   pinMode(Wyjscie_LED_STOP, OUTPUT);
  353.   pinMode(Wyjscie_Migacz_Lewy, OUTPUT);
  354.   pinMode(Wyjscie_Migacz_Prawy, OUTPUT);
  355.   pinMode(Wyjscie_Stacyjka, OUTPUT);
  356.   pinMode(Wyjscie_Alarm, OUTPUT);
  357.  
  358.   pinMode(Pomiar_Predkosci, INPUT_PULLUP);                            //linia do współpracy z hallotronem
  359.  
  360.   pinMode(Podswietlenie_PWM, OUTPUT);
  361.  
  362.   pinMode(lcd_gnd_RS, OUTPUT);
  363.   pinMode(lcd_gnd_RW, OUTPUT);
  364.   digitalWrite(lcd_gnd_RS, LOW);
  365.   digitalWrite(lcd_gnd_RW, LOW);
  366.  
  367.   d_kola = r_kola * 2 * PI;                                       //obwód kola
  368.  
  369.   Strona_2 = true;
  370.  
  371.   //=================================================
  372.   sensors.begin();
  373.   sensors.requestTemperatures();
  374.   dtostrf(sensors.getTempC(sensor1), 0, 1, RemoteXY.text_temperatura);
  375.  
  376.   delay (50);
  377.   u8g2.begin();
  378.  
  379.   Podswietlenie();
  380. }
  381.  
  382. void loop(void) {
  383.   aktualnyCzas = millis();
  384.   RemoteXY_Handler ();
  385.  
  386.   Pulpit();
  387.   Speed();
  388.   Temperatura();
  389.   d_total = readFromEEPROM();
  390.   Dystans();
  391.   sprintf(d_tot_str, " %d", d_total);
  392.  
  393.   //=================================
  394.   Bateria();
  395.   Stacyjka();
  396.   Alarm();
  397.  
  398.   //=================================
  399.  
  400.   stateButton_Klawisz_Menu = digitalRead(Wejscie_Klawisz_Menu);
  401.   if (stateButton_Klawisz_Menu == LOW && previous_Klawisz_Menu == LOW && millis() - time > debounce_Klawisz_Menu) {
  402.     if (stateRelay_Klawisz_Menu == HIGH) {
  403.       stateRelay_Klawisz_Menu = LOW;
  404.  
  405.       Strona_1 = true;
  406.       Strona_2 = false;
  407.  
  408.     } else {
  409.       stateRelay_Klawisz_Menu = HIGH;
  410.  
  411.       Strona_1 = false;
  412.       Strona_2 = true;
  413.     }
  414.     time = millis();
  415.   }
  416.   previous_Klawisz_Menu == stateButton_Klawisz_Menu;
  417.  
  418.   if (Strona_2 == true) {
  419.     u8g2.firstPage();
  420.     do {
  421.       //wypisanie Napiecia
  422.       u8g2.setFont(u8g2_font_profont11_tf);
  423.       u8g2.drawStr(124, 17, "BATERIA");
  424.  
  425.       u8g2.setFont(u8g_font_profont17r);        // select font
  426.       u8g2.drawRFrame(112, 18, 67, 20, 5);      // draws frame with rounded edges
  427.       u8g2.setCursor(119, 34);
  428.       u8g2.println(Suma_napiec);                //Prints the voltage
  429.       u8g2.println("V");
  430.  
  431.       Rysuj_skale();
  432.  
  433.       Ograniczenie();
  434.       Oswietlenie_1();
  435.       Oswietlenie_2();
  436.       Swiatlo_STOP();
  437.       Migacz_Lewy();
  438.       Migacz_Prawy();
  439.       Temperatura_BMP();
  440.       Ograniczenie_mocy_BMP();
  441.  
  442.  
  443.       Akumulator_BMP();
  444.       Ladowanie_BMP();
  445.       Swiatla_Pozycyjne_BMP();
  446.       Swiatla_Dlugie_BMP();
  447.  
  448.       Hamulec_BMP();
  449.       Strzalka_Lewa_BMP();
  450.       Strzalka_Prawa_BMP();
  451.  
  452.       //wypisanie prędkości
  453.       u8g2.setFont(u8g2_font_logisoso16_tn);
  454.  
  455.       //równanie wyniku pomiaru do ostatniej cyfry
  456.       if (m1_str.length() == 1 ) {
  457.         u8g2.drawStr(88, 63, m_str); //dla wyniku 1-cyfrowego
  458.       }
  459.       if (m1_str.length() == 2 ) {
  460.         u8g2.drawStr(78, 63, m_str); //dla wyniku 2-cyfrowego
  461.       }
  462.       /*    if (m1_str.length() == 3 ) {
  463.             u8g2.drawStr(82, 63, m_str); //dla wyniku 3-cyfrowego
  464.           }
  465.           if (m1_str.length() == 4 ) {
  466.             u8g2.drawStr(72, 63, m_str); //dla wyniku 4-cyfrowego
  467.           }
  468.       */
  469.  
  470.       //wypisanie kilometrażu całkowitego
  471.       u8g2.setFont(u8g2_font_profont11_tf);
  472.       u8g2.drawStr(50, 63, d_tot_str);
  473.       u8g2.setCursor(64, 63);
  474.       u8g2.println("km");
  475.  
  476.       //wypisanie długosci etapu
  477.       u8g2.drawStr(34, 55, de_str);
  478.       u8g2.drawStr(44, 55, ".");
  479.       u8g2.drawStr(50, 55, de1_str);
  480.       u8g2.drawStr(64, 55, "km");
  481.  
  482.       //wypisanie temperatury
  483.       u8g2.drawRFrame(112, 47, 67, 17, 5);     // draws frame with rounded edges
  484.  
  485.       u8g2.setFont(u8g2_font_profont11_tf);
  486.       u8g2.drawStr(113, 46, "TEMPERATURA");
  487.       u8g2.drawGlyph(160, 57, 176);
  488.  
  489.       u8g2.setFont(u8g_font_profont17r);        // select font
  490.       u8g2.setCursor(116, 61);
  491.       u8g2.println(sensors.getTempC(sensor1));
  492.       u8g2.setCursor(166, 61);
  493.       u8g2.println("C");
  494.  
  495.     } while ( u8g2.nextPage() );
  496.     delay(5);
  497.   }
  498. }
  499. int readFromEEPROM() {
  500.   byte high = EEPROM.read(1);
  501.   byte low = EEPROM.read(2);
  502.   return (high << 8) + low;
  503. }
Add Comment
Please, Sign In to add comment