Frästisch mit elektronischer Höhenverstellung mittels Schrittmotoren.
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

Display.cpp 2.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*
  2. * Display.cpp
  3. *
  4. * Wrapper class for Adafruit OLED display.
  5. *
  6. * Created on: 28.01.2022
  7. * Author: FSmilari
  8. */
  9. #include "Display.h"
  10. /*****************
  11. ** Constructors.
  12. ****************/
  13. Display::Display() {
  14. ssd1306 = Adafruit_SSD1306(SCREEN_WIDTH, SCREEN_HEIGHT);
  15. }
  16. /******************
  17. ** Public methods
  18. *****************/
  19. void Display::init() {
  20. if (!ssd1306.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS, true, true)) {
  21. Serial.println(F("SSD1306 allocation failed"));
  22. for (;;)
  23. ; // Don't proceed, loop forever
  24. }
  25. }
  26. void Display::display() {
  27. ssd1306.display();
  28. }
  29. void Display::clearDisplay() {
  30. ssd1306.clearDisplay();
  31. }
  32. void Display::showBrand() {
  33. ssd1306.clearDisplay();
  34. ssd1306.drawBitmap(0, 0, epd_bitmap_SFTools_Logo, 128, 34, SSD1306_WHITE);
  35. ssd1306.setFont(&titillium_web_semibold12pt7b);
  36. ssd1306.setTextSize(1);
  37. ssd1306.setTextColor(SSD1306_WHITE);
  38. uint16_t w = 0, h = 0;
  39. calculateWH("Fraestisch N172", w, h);
  40. ssd1306.setCursor((SCREEN_WIDTH - w) / 2, 63 - (30 - h) / 2);
  41. ssd1306.println("Fraestisch N172");
  42. display();
  43. }
  44. void Display::showInitialization() {
  45. ssd1306.clearDisplay();
  46. ssd1306.setFont(&titillium_web_semibold12pt7b);
  47. ssd1306.setTextSize(1);
  48. ssd1306.setTextColor(SSD1306_WHITE);
  49. uint16_t w = 0, h = 0;
  50. calculateWH("Initialisieren", w, h);
  51. ssd1306.setCursor((SCREEN_WIDTH - w) / 2, 30);
  52. ssd1306.println("Initialisieren");
  53. calculateWH(". . . . .", w, h);
  54. ssd1306.setCursor((SCREEN_WIDTH - w) / 2, 50);
  55. String s = "";
  56. for (int i = 0; i < 6; i++) {
  57. ssd1306.print(s);
  58. display();
  59. delay(500);
  60. if (i < 5) {
  61. ssd1306.print(s + ". ");
  62. } else {
  63. ssd1306.println(s + ".");
  64. }
  65. }
  66. }
  67. /********************************
  68. ** Private methods
  69. *******************************/
  70. void Display::calculateWH(String units, uint16_t &w, uint16_t &h) {
  71. int x = 0;
  72. int y = 0;
  73. int16_t x1, y1;
  74. uint16_t w1, h1;
  75. ssd1306.getTextBounds(units, x, y, &x1, &y1, &w1, &h1);
  76. w = w1;
  77. h = h1;
  78. }