Advertisement
Astranome

ANSI9

Jul 28th, 2020
324
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.15 KB | None | 0 0
  1.  /*
  2.   Created by Fabrizio Di Vittorio (fdivitto2013@gmail.com) - www.fabgl.com
  3.   Copyright (c) 2019-2020 Fabrizio Di Vittorio.
  4.   All rights reserved.
  5.  
  6.   This file is part of FabGL Library.
  7.  
  8.   FabGL is free software: you can redistribute it and/or modify
  9.   it under the terms of the GNU General Public License as published by
  10.   the Free Software Foundation, either version 3 of the License, or
  11.   (at your option) any later version.
  12.  
  13.   FabGL is distributed in the hope that it will be useful,
  14.   but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16.   GNU General Public License for more details.
  17.  
  18.   You should have received a copy of the GNU General Public License
  19.   along with FabGL.  If not, see <http://www.gnu.org/licenses/>.
  20.  */
  21.  
  22.  
  23. #include "fabgl.h"
  24.  
  25. fabgl::ILI9341Controller DisplayController;
  26. //fabgl::VGAController DisplayController;
  27. fabgl::PS2Controller PS2Controller;
  28. fabgl::Terminal      Terminal;
  29.  
  30. #define TFT_SCK    18
  31. #define TFT_MOSI   23
  32. #define TFT_CS     5
  33. #define TFT_DC     22
  34. #define TFT_RESET  21
  35. #define TFT_SPIBUS VSPI_HOST
  36.  
  37.  
  38. // notes about GPIO 2 and 12
  39. //    - GPIO2:  may cause problem on programming. GPIO2 must also be either left unconnected/floating, or driven Low, in order to enter the serial bootloader.
  40. //              In normal boot mode (GPIO0 high), GPIO2 is ignored.
  41. //    - GPIO12: should be avoided. It selects flash voltage. To use it disable GPIO12 detection setting efuses with:
  42. //                    python espefuse.py --port /dev/cu.SLAB_USBtoUART set_flash_voltage 3.3V
  43. //                       WARN!! Good for ESP32 with 3.3V voltage (ESP-WROOM-32). This will BRICK your ESP32 if the flash isn't 3.3V
  44. //                       NOTE1: replace "/dev/cu.SLAB_USBtoUART" with your serial port
  45. //                       NOTE2: espefuse.py is downloadable from https://github.com/espressif/esptool
  46. #define UART_RX 34
  47. #define UART_TX 2
  48.  
  49.  
  50. #include "confdialog.h"
  51.  
  52.  
  53. void setup()
  54. {
  55.   //Serial.begin(115200); delay(500); Serial.write("\n\nReset\n\n"); // DEBUG ONLY
  56.  
  57.   preferences.begin("AnsiTerminal", false);
  58.   //preferences.clear();
  59.  
  60.   // only keyboard configured on port 0
  61.   PS2Controller.begin(PS2Preset::KeyboardPort0);
  62.  
  63. //  DisplayController.begin();
  64.   //DisplayController.setResolution(VGA_640x350_70HzAlt1);
  65.   //DisplayController.setResolution(VGA_640x480_60Hz, 640, 350);
  66.   DisplayController.begin(TFT_SCK, TFT_MOSI, TFT_DC, TFT_RESET, TFT_CS, TFT_SPIBUS);
  67.   DisplayController.setResolution(TFT_240x320);
  68.   DisplayController.setOrientation(fabgl::TFTOrientation::Rotate90);
  69.  
  70.   Terminal.begin(&DisplayController);
  71.   //Terminal.setLogStream(Serial);  // debug only
  72.  
  73.   ConfDialogApp::loadConfiguration();
  74.   Terminal.loadFont(&fabgl::FONT_6x10);
  75.   Terminal.clear();
  76.   Terminal.enableCursor(true);
  77.  
  78.   Terminal.write("* *  FabGL - Serial Terminal                            * *\r\n");
  79.   Terminal.write("* *  2019-2020 by Fabrizio Di Vittorio - www.fabgl.com  * *\r\n\n");
  80.   //Terminal.printf("Screen Size        : %d x %d\r\n", DisplayController.getScreenWidth(), DisplayController.getScreenHeight());
  81.   Terminal.printf("Terminal Size      : %d x %d\r\n", Terminal.getColumns(), Terminal.getRows());
  82.   Terminal.printf("Keyboard           : %s\r\n", PS2Controller.keyboard()->isKeyboardAvailable() ? "OK" : "Error");
  83.   Terminal.printf("Terminal Type      : %s\r\n", SupportedTerminals::names()[(int)ConfDialogApp::getTermType()]);
  84.   //Terminal.printf("Free Memory        : %d bytes\r\n", heap_caps_get_free_size(MALLOC_CAP_32BIT));
  85.   Terminal.write("\r\nPress F12 to change terminal configuration\r\n\n");
  86.  
  87.   // look for F12 key to open configuration dialog
  88.   Terminal.onVirtualKey = [&](VirtualKey * vk, bool keyDown) {
  89.     if (*vk == VirtualKey::VK_F12) {
  90.       if (!keyDown) {
  91.         Terminal.deactivate();
  92.         auto dlgApp = new ConfDialogApp;
  93.         dlgApp->run(&DisplayController);
  94.         delete dlgApp;
  95.         Terminal.keyboard()->emptyVirtualKeyQueue();
  96.         Terminal.activate();
  97.       }
  98.       *vk = VirtualKey::VK_NONE;
  99.     }
  100.   };
  101. }
  102.  
  103.  
  104. void loop()
  105. {
  106.   // the job is done using UART interrupts
  107.   vTaskDelete(NULL);
  108. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement