_oLED.ino 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. // 1-channel LoRa Gateway for ESP8266
  2. // Copyright (c) 2016, 2017, 2018, 2019 Maarten Westenberg version for ESP8266
  3. // Version 6.1.3
  4. // Date: 2019-11-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, 0, "READY, SSID=");
  59. display.drawString(0, 16, WiFi.SSID());
  60. display.drawString(0, 32, "IP=");
  61. display.drawString(0, 48, WiFi.localIP().toString().c_str() );
  62. #elif OLED==2
  63. display.setFont(ArialMT_Plain_16);
  64. display.drawString(0, 0, "READY, SSID=");
  65. display.drawString(0, 16, WiFi.SSID());
  66. display.drawString(0, 32, "IP=");
  67. display.drawString(0, 48, WiFi.localIP().toString().c_str() );
  68. #endif
  69. display.display();
  70. delay(4000);
  71. }
  72. // --------------------------------------------------------------------
  73. // Print a message on the OLED.
  74. // Note: The whole message must fit in the buffer
  75. //
  76. // --------------------------------------------------------------------
  77. void msg_oLED(String tim, String sf) {
  78. display.clear();
  79. display.setFont(ArialMT_Plain_16);
  80. display.setTextAlignment(TEXT_ALIGN_LEFT);
  81. display.drawString(0, 48, "LEN: " );
  82. // display.drawString(40, 48, String((int)messageLength) );
  83. display.display();
  84. yield();
  85. }
  86. // --------------------------------------------------------------------
  87. // Print the OLED address in use
  88. //
  89. // --------------------------------------------------------------------
  90. void addr_oLED()
  91. {
  92. Serial.print(F("OLED_ADDR=0x"));
  93. Serial.println(OLED_ADDR, HEX);
  94. }
  95. #endif