_oLED.ino 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. // 1-channel LoRa Gateway for ESP8266
  2. // Copyright (c) 2016, 2017, 2018, 2019 Maarten Westenberg version for ESP8266
  3. // Version 6.1.0
  4. // Date: 2019-10-20
  5. //
  6. // based on work done by Thomas Telkamp for Raspberry PI 1ch gateway
  7. // and many others.
  8. //
  9. // All rights reserved. This program and the accompanying materials
  10. // are made available under the terms of the MIT License
  11. // which accompanies this distribution, and is available at
  12. // https://opensource.org/licenses/mit-license.php
  13. //
  14. // NO WARRANTY OF ANY KIND IS PROVIDED
  15. //
  16. // Author: Maarten Westenberg (mw12554@hotmail.com)
  17. //
  18. // This file contains the state machine code enabling to receive
  19. // and transmit packages/messages.
  20. // ========================================================================================
  21. //
  22. #if OLED>=1
  23. // --------------------------------------------------------------------
  24. // Initilize the OLED functions.
  25. // This function will init the OLED screenb. Depending on the
  26. // availability of the reset button it will reset the display first.
  27. // --------------------------------------------------------------------
  28. void init_oLED()
  29. {
  30. #if defined OLED_RST
  31. pinMode(OLED_RST,OUTPUT);
  32. digitalWrite(OLED_RST, LOW); // low to reset OLED
  33. delay(100);
  34. digitalWrite(OLED_RST, HIGH); // must be high to turn on OLED
  35. delay(50);
  36. #else
  37. #endif
  38. // Initialising the UI will init the display too.
  39. display.init();
  40. delay(100);
  41. //display.begin(SSD1306_SWITCHCAPVCC, OLED_ADDR, FALSE)
  42. display.flipScreenVertically();
  43. display.setFont(ArialMT_Plain_24);
  44. display.setTextAlignment(TEXT_ALIGN_LEFT);
  45. display.drawString(0, 24, "STARTING");
  46. display.display();
  47. }
  48. // --------------------------------------------------------------------
  49. // Activate the OLED
  50. //
  51. // --------------------------------------------------------------------
  52. void acti_oLED()
  53. {
  54. // Initialising the UI will init the display too.
  55. display.clear();
  56. #if OLED==1
  57. display.setFont(ArialMT_Plain_16);
  58. display.drawString(0, 16, "READY, SSID=");
  59. display.drawString(0, 32, WiFi.SSID());
  60. #elif OLED==2
  61. display.setFont(ArialMT_Plain_16);
  62. display.drawString(0, 16, "READY, SSID=");
  63. display.drawString(0, 32, WiFi.SSID());
  64. #endif
  65. display.display();
  66. }
  67. // --------------------------------------------------------------------
  68. // Print a message on the OLED.
  69. // Note: The whole message must fit in the buffer
  70. //
  71. // --------------------------------------------------------------------
  72. void msg_oLED(String tim, String sf) {
  73. display.clear();
  74. display.setFont(ArialMT_Plain_16);
  75. display.setTextAlignment(TEXT_ALIGN_LEFT);
  76. display.drawString(0, 48, "LEN: " );
  77. // display.drawString(40, 48, String((int)messageLength) );
  78. display.display();
  79. yield();
  80. }
  81. // --------------------------------------------------------------------
  82. // Print the OLED address in use
  83. //
  84. // --------------------------------------------------------------------
  85. void addr_oLED()
  86. {
  87. Serial.print(F("OLED_ADDR=0x"));
  88. Serial.println(OLED_ADDR, HEX);
  89. }
  90. #endif