├── .gitignore ├── lib ├── src │ ├── gitTagVersion.h │ ├── Fonts │ │ ├── ASC16 │ │ ├── HZK16 │ │ ├── TrueType │ │ │ └── Not_yet_supported.txt │ │ ├── Font16.h │ │ ├── Font32rle.h │ │ ├── Font64rle.h │ │ ├── Font72rle.h │ │ ├── Font7srle.h │ │ ├── GFXFF │ │ │ ├── gfxfont.h │ │ │ ├── license.txt │ │ │ ├── print.txt │ │ │ ├── FreeMono9pt7b.h │ │ │ ├── FreeMonoOblique9pt7b.h │ │ │ └── FreeMonoBold9pt7b.h │ │ ├── glcdfont.c │ │ └── Font7srle.c │ ├── M5Faces.h │ ├── utility │ │ ├── quaternionFilters.h │ │ ├── Config.h │ │ ├── Speaker.h │ │ ├── CommUtil.h │ │ ├── MahonyAHRS.h │ │ ├── Speaker.cpp │ │ ├── SH200Q.h │ │ ├── Button.h │ │ ├── ILI9341_Rotation.h │ │ ├── Power.h │ │ ├── qrcode.h │ │ ├── MPU6886.h │ │ ├── ILI9341_Init.h │ │ ├── pngle.h │ │ ├── M5Timer.h │ │ ├── ILI9341_Defines.h │ │ ├── CommUtil.cpp │ │ ├── M5Timer.cpp │ │ ├── Button.cpp │ │ ├── MPU6886.cpp │ │ ├── SH200Q.cpp │ │ ├── Sprite.h │ │ ├── MahonyAHRS.cpp │ │ ├── MPU9250.h │ │ └── quaternionFilters.cpp │ ├── M5Faces.cpp │ ├── M5Stack.cpp │ ├── M5LoRa.h │ ├── M5Display.h │ ├── M5Stack.h │ └── Free_Fonts.h └── README ├── image └── iot_base_nb_factorytest.jpg ├── src ├── resource.h ├── Task.h ├── TFTTerminal.h ├── StringList.h ├── Task.cpp ├── simcom.h ├── simcom.cpp └── TFTTerminal.cpp ├── README.md └── platformio.ini /.gitignore: -------------------------------------------------------------------------------- 1 | .pio 2 | .vscode -------------------------------------------------------------------------------- /lib/src/gitTagVersion.h: -------------------------------------------------------------------------------- 1 | #define M5_LIB_VERSION F("0.2.3-dirty") 2 | -------------------------------------------------------------------------------- /lib/src/Fonts/ASC16: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m5stack/IoT_BASE_NB_FactoryTest/master/lib/src/Fonts/ASC16 -------------------------------------------------------------------------------- /lib/src/Fonts/HZK16: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m5stack/IoT_BASE_NB_FactoryTest/master/lib/src/Fonts/HZK16 -------------------------------------------------------------------------------- /lib/src/Fonts/TrueType/Not_yet_supported.txt: -------------------------------------------------------------------------------- 1 | TO DO: Add support for converted True Type fonts in an RLE format. -------------------------------------------------------------------------------- /image/iot_base_nb_factorytest.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m5stack/IoT_BASE_NB_FactoryTest/master/image/iot_base_nb_factorytest.jpg -------------------------------------------------------------------------------- /lib/src/Fonts/Font16.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #define nr_chrs_f16 96 4 | #define chr_hgt_f16 16 5 | #define baseline_f16 13 6 | #define data_size_f16 8 7 | #define firstchr_f16 32 8 | 9 | extern const unsigned char widtbl_f16[96]; 10 | extern const unsigned char* const chrtbl_f16[96]; 11 | -------------------------------------------------------------------------------- /lib/src/Fonts/Font32rle.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #define nr_chrs_f32 96 4 | #define chr_hgt_f32 26 5 | #define baseline_f32 19 6 | #define data_size_f32 8 7 | #define firstchr_f32 32 8 | 9 | extern const unsigned char widtbl_f32[96]; 10 | extern const unsigned char* const chrtbl_f32[96]; 11 | -------------------------------------------------------------------------------- /lib/src/Fonts/Font64rle.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #define nr_chrs_f64 96 4 | #define chr_hgt_f64 48 5 | #define baseline_f64 36 6 | #define data_size_f64 8 7 | #define firstchr_f64 32 8 | 9 | extern const unsigned char widtbl_f64[96]; 10 | extern const unsigned char* const chrtbl_f64[96]; 11 | -------------------------------------------------------------------------------- /lib/src/Fonts/Font72rle.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #define nr_chrs_f72 96 4 | #define chr_hgt_f72 75 5 | #define baseline_f72 73 6 | #define data_size_f72 8 7 | #define firstchr_f72 32 8 | 9 | extern const unsigned char widtbl_f72[96]; 10 | extern const unsigned char* const chrtbl_f72[96]; 11 | -------------------------------------------------------------------------------- /lib/src/Fonts/Font7srle.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #define nr_chrs_f7s 96 4 | #define chr_hgt_f7s 48 5 | #define baseline_f7s 47 6 | #define data_size_f7s 8 7 | #define firstchr_f7s 32 8 | 9 | extern const unsigned char widtbl_f7s[96]; 10 | extern const unsigned char* const chrtbl_f7s[96]; 11 | -------------------------------------------------------------------------------- /lib/src/M5Faces.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) M5Stack. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | #ifndef M5Faces_h 4 | #define M5Faces_h 5 | 6 | #include "M5Stack.h" 7 | 8 | class M5Faces { 9 | public: 10 | M5Faces(); 11 | bool canControlFaces(); 12 | uint8_t getch(void); 13 | bool kbhit(void); 14 | private: 15 | }; 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /src/resource.h: -------------------------------------------------------------------------------- 1 | #ifndef _RESOURCE_H_ 2 | #define _RESOURCE_H_ 3 | 4 | extern const unsigned char image_message[135]; 5 | extern const unsigned char image_NetWork[135]; 6 | extern const unsigned char image_Signal[135]; 7 | extern const unsigned char image_SIMCard[135]; 8 | extern const unsigned char nb_iot_bk_jpeg[50695]; 9 | extern const unsigned char part1_portc_jpeg_img[14547]; 10 | extern const unsigned char part1_rs485_jpeg_img[14470]; 11 | extern const unsigned char qrcode_img[19554]; 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## IoT Base NB FactoryTest 2 | 3 | This project is built using PlatformIO, using [M5Stack IoT Base NB](https://docs.m5stack.com/en/base/iot_base_nb_cn) controller suite access [TVOC/eCO2 UNIT(SGP30 Sensor)](https://docs.m5stack.com/en/unit/tvoc), realize MQTT data upload through NBIoT network. 4 | 5 | ![iot_base_nb_factorytest_pic](./image/iot_base_nb_factorytest.jpg) 6 | 7 | ## Related Link 8 | 9 | [Document & Datasheet](https://docs.m5stack.com/en/base/iot_base_nb_cn) 10 | 11 | ## Required Libraries: 12 | 13 | [Adafruit_SGP30](https://github.com/adafruit/Adafruit_SGP30) 14 | -------------------------------------------------------------------------------- /lib/src/utility/quaternionFilters.h: -------------------------------------------------------------------------------- 1 | #ifndef _QUATERNIONFILTERS_H_ 2 | #define _QUATERNIONFILTERS_H_ 3 | 4 | #include 5 | 6 | void MadgwickQuaternionUpdate(float ax, float ay, float az, float gx, float gy, 7 | float gz, float mx, float my, float mz, 8 | float deltat); 9 | void MahonyQuaternionUpdate(float ax, float ay, float az, float gx, float gy, 10 | float gz, float mx, float my, float mz, 11 | float deltat); 12 | const float * getQ(); 13 | 14 | #endif // _QUATERNIONFILTERS_H_ 15 | -------------------------------------------------------------------------------- /platformio.ini: -------------------------------------------------------------------------------- 1 | ; PlatformIO Project Configuration File 2 | ; 3 | ; Build options: build flags, source filter 4 | ; Upload options: custom upload port, speed and extra flags 5 | ; Library options: dependencies, extra library storages 6 | ; Advanced options: extra scripting 7 | ; 8 | ; Please visit documentation for the other options and examples 9 | ; https://docs.platformio.org/page/projectconf.html 10 | 11 | [env:m5stack-core-esp32] 12 | platform = espressif32 13 | board = m5stack-core-esp32 14 | framework = arduino 15 | upload_speed = 921600 16 | monitor_speed = 115200 17 | board_build.partitions = no_ota.csv 18 | lib_deps = adafruit/Adafruit SGP30 Sensor@^2.0.0 19 | -------------------------------------------------------------------------------- /src/Task.h: -------------------------------------------------------------------------------- 1 | #ifndef _TASK_PERSION_H_ 2 | #define _TASK_PERSION_H_ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | class Task 9 | { 10 | public: 11 | Task(std::string taskName="task", uint16_t taskSize = 10240, uint8_t priority = 5); 12 | ~Task(); 13 | void start(void* taskData = nullptr ); 14 | void stop(); 15 | 16 | void delay(int ms); 17 | 18 | virtual void run(void* data) = 0; 19 | 20 | void setTaskSize( uint16_t size ); 21 | void setTaskPriority( uint8_t priority); 22 | void setTaskName(std::string name); 23 | void setCore(BaseType_t coreID); 24 | 25 | private: 26 | xTaskHandle m_handle; 27 | void* m_taskdata; 28 | static void runTask(void* data); 29 | std::string m_taskname; 30 | uint16_t m_tasksize; 31 | uint8_t m_priority; 32 | BaseType_t m_coreid; 33 | /* data */ 34 | }; 35 | 36 | 37 | 38 | 39 | #endif -------------------------------------------------------------------------------- /lib/src/utility/Config.h: -------------------------------------------------------------------------------- 1 | #ifndef _CONFIG_H_ 2 | #define _CONFIG_H_ 3 | 4 | // Screen 5 | #define TFT_LED_PIN 32 6 | #define TFT_DC_PIN 27 7 | #define TFT_CS_PIN 14 8 | #define TFT_MOSI_PIN 23 9 | #define TFT_CLK_PIN 18 10 | #define TFT_RST_PIN 33 11 | #define TFT_MISO_PIN 19 12 | 13 | // SD card 14 | #define TFCARD_CS_PIN 4 15 | 16 | // Buttons 17 | #define BTN_A 0 18 | #define BTN_B 1 19 | #define BTN_C 2 20 | #define BUTTON_A 0 21 | #define BUTTON_B 1 22 | #define BUTTON_C 2 23 | #define BUTTON_A_PIN 39 24 | #define BUTTON_B_PIN 38 25 | #define BUTTON_C_PIN 37 26 | 27 | // BEEP PIN 28 | #define SPEAKER_PIN 25 29 | #define TONE_PIN_CHANNEL 0 30 | 31 | // LORA 32 | #define LORA_CS_PIN 5 33 | #define LORA_RST_PIN 26 34 | #define LORA_IRQ_PIN 36 35 | 36 | // UART 37 | #define USE_SERIAL Serial 38 | 39 | #endif /* SETTINGS_C */ 40 | -------------------------------------------------------------------------------- /src/TFTTerminal.h: -------------------------------------------------------------------------------- 1 | #ifndef _TFTTERMINAL_H_ 2 | #define _TFTTERMINAL_H_ 3 | 4 | #include 5 | #include 6 | 7 | class TFTTerminal : public Print 8 | { 9 | private: 10 | TFT_eSprite *disptr; 11 | char discharbuff[60][55]; 12 | uint32_t xpos = 0,ypos = 0, dispos = 0; 13 | TFT_eSprite* _dis_buff_ptr = NULL; 14 | uint16_t _bkcolor = TFT_BLACK; 15 | uint16_t _color = TFT_GREEN; 16 | 17 | uint16_t _win_x_pos = 0,_win_y_pos = 0,_win_w = 320,_win_h = 240; 18 | uint16_t _font_x_size = 6,_font_y_size = 10; 19 | uint8_t _fontSize = 0; 20 | uint16_t _line_x_limit = 53,_line_y_limit = 30; 21 | 22 | public: 23 | TFTTerminal(TFT_eSprite *dis_buff_ptr); 24 | ~TFTTerminal(); 25 | 26 | void setcolor( uint16_t color, uint16_t bk_color ); 27 | void setGeometry(uint16_t x, uint16_t y, uint16_t w, uint16_t h ); 28 | void setFontsize(uint8_t size); 29 | 30 | size_t write(uint8_t) ; 31 | size_t write(const uint8_t *buffer, size_t size); 32 | }; 33 | 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /lib/src/utility/Speaker.h: -------------------------------------------------------------------------------- 1 | #ifndef _SPEAKER_H_ 2 | #define _SPEAKER_H_ 3 | 4 | #include "Arduino.h" 5 | #include "Config.h" 6 | 7 | #ifdef __cplusplus 8 | extern "C" 9 | { 10 | #endif /* __cplusplus */ 11 | #include "esp32-hal-dac.h" 12 | #ifdef __cplusplus 13 | } 14 | #endif /* __cplusplus */ 15 | 16 | class SPEAKER { 17 | public: 18 | SPEAKER(void); 19 | 20 | void begin(); 21 | void end(); 22 | void mute(); 23 | void tone(uint16_t frequency); 24 | void tone(uint16_t frequency, uint32_t duration); 25 | void beep(); 26 | void setBeep(uint16_t frequency, uint16_t duration); 27 | void update(); 28 | 29 | void write(uint8_t value); 30 | void setVolume(uint8_t volume); 31 | void playMusic(const uint8_t *music_data, uint16_t sample_rate); 32 | 33 | private: 34 | uint32_t _count; 35 | uint8_t _volume; 36 | uint16_t _beep_duration; 37 | uint16_t _beep_freq; 38 | bool _begun; 39 | bool speaker_on; 40 | }; 41 | #endif 42 | -------------------------------------------------------------------------------- /lib/src/M5Faces.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) M5Stack. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | #include "M5Faces.h" 5 | 6 | // ================ Faces Keyboard =================== 7 | #define KEYBOARD_I2C_ADDR 0x08 8 | #define KEYBOARD_INT 5 9 | #define READI2CSUBADDR 0 10 | 11 | /*----------------------------------------------------------------------* 12 | * Extentions for Facces * 13 | *----------------------------------------------------------------------*/ 14 | bool M5Faces::canControlFaces() { 15 | return M5.I2C.writeCommand(KEYBOARD_I2C_ADDR,READI2CSUBADDR); 16 | } 17 | 18 | M5Faces::M5Faces() { 19 | pinMode(KEYBOARD_INT, INPUT_PULLUP); 20 | } 21 | 22 | uint8_t M5Faces::getch(void) { 23 | uint8_t data=0x00; 24 | 25 | if (kbhit()) { 26 | 27 | while (data==0x00){ 28 | if (!M5.I2C.readByte(KEYBOARD_I2C_ADDR,&data)) { 29 | return 0x00; 30 | } 31 | delay(1); 32 | } 33 | return data; 34 | } 35 | return 0x00; 36 | } 37 | 38 | bool M5Faces::kbhit(void) { 39 | return(digitalRead(KEYBOARD_INT) == LOW); 40 | } 41 | -------------------------------------------------------------------------------- /lib/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for project specific (private) libraries. 3 | PlatformIO will compile them to static libraries and link into executable file. 4 | 5 | The source code of each library should be placed in a an own separate directory 6 | ("lib/your_library_name/[here are source files]"). 7 | 8 | For example, see a structure of the following two libraries `Foo` and `Bar`: 9 | 10 | |--lib 11 | | | 12 | | |--Bar 13 | | | |--docs 14 | | | |--examples 15 | | | |--src 16 | | | |- Bar.c 17 | | | |- Bar.h 18 | | | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html 19 | | | 20 | | |--Foo 21 | | | |- Foo.c 22 | | | |- Foo.h 23 | | | 24 | | |- README --> THIS FILE 25 | | 26 | |- platformio.ini 27 | |--src 28 | |- main.c 29 | 30 | and a contents of `src/main.c`: 31 | ``` 32 | #include 33 | #include 34 | 35 | int main (void) 36 | { 37 | ... 38 | } 39 | 40 | ``` 41 | 42 | PlatformIO Library Dependency Finder will find automatically dependent 43 | libraries scanning project source files. 44 | 45 | More information about PlatformIO Library Dependency Finder 46 | - https://docs.platformio.org/page/librarymanager/ldf.html 47 | -------------------------------------------------------------------------------- /lib/src/utility/CommUtil.h: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------------------* 2 | * M5Stack I2C Common Library v1.0 * 3 | * * 4 | * This work is licensed under the GNU Lesser General Public * 5 | * License v2.1 * 6 | * https://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html * 7 | *----------------------------------------------------------------------*/ 8 | #ifndef CommUtil_h 9 | #define CommUtil_h 10 | 11 | #include 12 | #include 13 | 14 | class CommUtil { 15 | public: 16 | CommUtil(); 17 | bool writeCommand(uint8_t address, uint8_t subAddress); 18 | bool writeByte(uint8_t address, uint8_t subAddress, uint8_t data); 19 | bool writeBytes(uint8_t address, uint8_t subAddress, uint8_t *data,uint8_t length); 20 | bool readByte(uint8_t address, uint8_t *result); 21 | bool readByte(uint8_t address, uint8_t subAddress,uint8_t *result); 22 | bool readBytes(uint8_t address, uint8_t count,uint8_t * dest); 23 | bool readBytes(uint8_t address, uint8_t subAddress, uint8_t count, uint8_t * dest); 24 | void scanID(bool *result); 25 | private: 26 | }; 27 | #endif 28 | -------------------------------------------------------------------------------- /lib/src/Fonts/GFXFF/gfxfont.h: -------------------------------------------------------------------------------- 1 | // Adopted by Bodmer to support TFT_HX8357_Due library. 2 | 3 | // Font structures for newer Adafruit_GFX (1.1 and later). 4 | // Example fonts are included in 'Fonts' directory. 5 | // To use a font in your Arduino sketch, #include the corresponding .h 6 | // file and pass address of GFXfont struct to setFont(). Pass NULL to 7 | // revert to 'classic' fixed-space bitmap font. 8 | 9 | #ifndef _GFXFONT_H_ 10 | #define _GFXFONT_H_ 11 | 12 | #ifdef LOAD_GFXFF 13 | 14 | typedef struct { // Data stored PER GLYPH 15 | uint32_t bitmapOffset; // Pointer into GFXfont->bitmap 16 | uint8_t width, height; // Bitmap dimensions in pixels 17 | uint8_t xAdvance; // Distance to advance cursor (x axis) 18 | int8_t xOffset, yOffset; // Dist from cursor pos to UL corner 19 | } GFXglyph; 20 | 21 | #ifdef USE_M5_FONT_CREATOR 22 | typedef struct { 23 | uint16_t start; 24 | uint16_t end; 25 | uint16_t base; 26 | } EncodeRange; 27 | #endif 28 | 29 | typedef struct { // Data stored for FONT AS A WHOLE: 30 | uint8_t *bitmap; // Glyph bitmaps, concatenated 31 | GFXglyph *glyph; // Glyph array 32 | uint16_t first, last; // ASCII extents 33 | uint8_t yAdvance; // Newline distance (y axis) 34 | #ifdef USE_M5_FONT_CREATOR 35 | uint16_t range_num; 36 | EncodeRange *range; 37 | uint8_t smooth_bpp; 38 | #endif 39 | } GFXfont; 40 | 41 | #endif // LOAD_GFXFF 42 | 43 | #endif // _GFXFONT_H_ -------------------------------------------------------------------------------- /src/StringList.h: -------------------------------------------------------------------------------- 1 | #ifndef _STRINGLIST_H_ 2 | #define _STRINGLIST_H_ 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | using namespace std; 9 | 10 | class StringList 11 | { 12 | public: 13 | StringList(){}; 14 | StringList(std::initializer_list args ){ for( const String &item : args ){ _list.push_back(item);}}; 15 | StringList(String str,char c){ this->split(str,c);}; 16 | ~StringList(){}; 17 | 18 | String at(int i){ return _list.at(i);} 19 | size_t size(){ return _list.size();} 20 | 21 | int split(String str,char c) 22 | { 23 | if( str.isEmpty()){ return 0;} 24 | _list.clear(); 25 | int index = -1; 26 | do{ 27 | index = str.indexOf(','); 28 | if( index > 0 ) 29 | { 30 | String _str = str.substring(0,index); 31 | if( !_str.isEmpty()){ _list.push_back(_str); } 32 | str = str.substring(index + 1); 33 | } 34 | else if( index < 0 ){ if( !str.isEmpty()){ _list.push_back(str); break;}} 35 | else{ str = str.substring(0,1);} 36 | }while(!str.isEmpty()); 37 | 38 | return _list.size(); 39 | } 40 | 41 | void showList(Print *p) 42 | { 43 | p->print("[LIST]"); 44 | for (int i = 0; i < _list.size(); i++) 45 | { 46 | p->printf("%s ",_list.at(i).c_str()); 47 | } 48 | p->println(" "); 49 | } 50 | 51 | private: 52 | vector_list; 53 | }; 54 | 55 | 56 | #endif -------------------------------------------------------------------------------- /src/Task.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include "Task.h" 7 | 8 | static char tag[] = "Task"; 9 | 10 | Task::Task(std::string taskName, uint16_t taskSize, uint8_t priority) 11 | { 12 | m_handle = nullptr; 13 | m_taskdata = nullptr; 14 | m_taskname = taskName; 15 | m_tasksize = taskSize; 16 | m_priority = priority; 17 | m_coreid = 1; 18 | } 19 | 20 | Task::~Task() 21 | { 22 | } 23 | 24 | void Task::runTask(void* pTaskInstance) 25 | { 26 | Task* pTask = (Task*)pTaskInstance; 27 | ESP_LOGD(tag, ">> Task %s run", pTask->m_taskname.c_str()); 28 | pTask->run(pTask->m_taskdata); 29 | ESP_LOGD(tag, "<< Task %s stop", pTask->m_taskname.c_str()); 30 | pTask->stop(); 31 | } 32 | 33 | void Task::start(void* taskData) 34 | { 35 | if( m_handle != nullptr ) 36 | { 37 | ESP_LOGD(tag, "[] Task %s is already running", m_taskname.c_str()); 38 | } 39 | m_taskdata = taskData; 40 | ::xTaskCreatePinnedToCore(&runTask, m_taskname.c_str(), m_tasksize, this, m_priority, &m_handle, m_coreid); 41 | } 42 | 43 | void Task::stop() 44 | { 45 | if( m_handle == nullptr ) 46 | { 47 | return; 48 | } 49 | xTaskHandle handleTemp = m_handle; 50 | m_handle = nullptr; 51 | ::vTaskDelete(handleTemp); 52 | } 53 | 54 | void Task::delay(int ms) 55 | { 56 | ::vTaskDelay(ms/portTICK_PERIOD_MS); 57 | } 58 | 59 | void Task::setTaskSize( uint16_t size ) 60 | { 61 | m_tasksize = size; 62 | } 63 | 64 | void Task::setTaskPriority( uint8_t priority) 65 | { 66 | m_priority = priority; 67 | } 68 | 69 | void Task::setTaskName(std::string name) 70 | { 71 | m_taskname = name; 72 | } 73 | 74 | void Task::setCore(BaseType_t coreID) 75 | { 76 | m_coreid = coreID; 77 | } 78 | 79 | -------------------------------------------------------------------------------- /lib/src/Fonts/GFXFF/license.txt: -------------------------------------------------------------------------------- 1 | This TFT_eSPI library has been developed from the Adafruit_GFX library: 2 | 3 | https://github.com/adafruit/Adafruit-GFX-Library 4 | 5 | It has been modified extensively to improve rendering speed on 6 | ESP8266 processors. There follows the original library license text. 7 | 8 | 9 | Original text follows: 10 | 11 | Software License Agreement (BSD License) 12 | 13 | Copyright (c) 2012 Adafruit Industries. All rights reserved. 14 | 15 | Redistribution and use in source and binary forms, with or without 16 | modification, are permitted provided that the following conditions are met: 17 | 18 | - Redistributions of source code must retain the above copyright notice, 19 | this list of conditions and the following disclaimer. 20 | - Redistributions in binary form must reproduce the above copyright notice, 21 | this list of conditions and the following disclaimer in the documentation 22 | and/or other materials provided with the distribution. 23 | 24 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 25 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 26 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 27 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 28 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 29 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 30 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 31 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 32 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 33 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 34 | POSSIBILITY OF SUCH DAMAGE. 35 | -------------------------------------------------------------------------------- /src/simcom.h: -------------------------------------------------------------------------------- 1 | #ifndef _SIMCOM_H_ 2 | #define _SIMCOM_H_ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | 10 | #define LOG_ENABLE 11 | #define DEBUG_ENABLE 12 | 13 | #define LOG_ASYNC 14 | 15 | #ifndef LOG_ASYNC 16 | #define SIMCOM_LOG( format, ... ) \ 17 | Serial.printf(format, ##__VA_ARGS__);if(_log != nullptr){_log->printf( format, ##__VA_ARGS__);} 18 | #else 19 | #define SIMCOM_LOG( format, ... ) do{\ 20 | Serial.printf(format, ##__VA_ARGS__);\ 21 | if(_log != nullptr){\ 22 | char* buffptr = nullptr;\ 23 | asprintf(&buffptr,format, ##__VA_ARGS__);\ 24 | if( buffptr != nullptr ){if( xQueueSend(logQueue, &buffptr, (TickType_t)10) == pdFALSE ){free(buffptr);}}}\ 25 | }while(0); 26 | #endif 27 | 28 | class simcom 29 | { 30 | public: 31 | simcom(){} 32 | ~simcom(){} 33 | void begin(HardwareSerial & uart,Print *stream = nullptr); 34 | 35 | void setlogStream(Print *stream){_log = stream;}; 36 | 37 | void sendCMD(String str); 38 | int sendCMDAndFindUntil(String str,std::initializer_list args,int retry = 5,int max_line = 10,int timeout = 1000); 39 | int sendCMDAndWaitRevice(String str,std::initializer_list args,String reviceMark,String *revidePtr = nullptr,int retry = 5,int max_line = 10,int timeout = 1000); 40 | int waitUntill(String reviceMark,String *revidePtr = nullptr,int timeout = 10); 41 | String sendCMDAndRevice(String str); 42 | 43 | #ifdef LOG_ASYNC 44 | QueueHandle_t logQueue = nullptr; 45 | #endif 46 | 47 | private: 48 | HardwareSerial *_serialPtr = nullptr; 49 | Print *_log = nullptr; 50 | 51 | 52 | 53 | 54 | }; 55 | 56 | 57 | #endif -------------------------------------------------------------------------------- /lib/src/utility/MahonyAHRS.h: -------------------------------------------------------------------------------- 1 | //===================================================================================================== 2 | // MahonyAHRS.h 3 | //===================================================================================================== 4 | // 5 | // Madgwick's implementation of Mayhony's AHRS algorithm. 6 | // See: http://www.x-io.co.uk/node/8#open_source_ahrs_and_imu_algorithms 7 | // 8 | // Date Author Notes 9 | // 29/09/2011 SOH Madgwick Initial release 10 | // 02/10/2011 SOH Madgwick Optimised for reduced CPU load 11 | // 12 | //===================================================================================================== 13 | #ifndef MahonyAHRS_h 14 | #define MahonyAHRS_h 15 | 16 | //---------------------------------------------------------------------------------------------------- 17 | // Variable declaration 18 | 19 | extern volatile float twoKp; // 2 * proportional gain (Kp) 20 | extern volatile float twoKi; // 2 * integral gain (Ki) 21 | //volatile float q0, q1, q2, q3; // quaternion of sensor frame relative to auxiliary frame 22 | 23 | //--------------------------------------------------------------------------------------------------- 24 | // Function declarations 25 | 26 | void MahonyAHRSupdate(float gx, float gy, float gz, float ax, float ay, float az, float mx, float my, float mz); 27 | //void MahonyAHRSupdateIMU(float gx, float gy, float gz, float ax, float ay, float az); 28 | void MahonyAHRSupdateIMU(float gx, float gy, float gz, float ax, float ay, float az,float *pitch,float *roll,float *yaw); 29 | float invSqrt(float x); 30 | #endif 31 | //===================================================================================================== 32 | // End of file 33 | //===================================================================================================== 34 | -------------------------------------------------------------------------------- /lib/src/Fonts/GFXFF/print.txt: -------------------------------------------------------------------------------- 1 | #define TT1 TomThumb 2 | 3 | #define FF1 FreeMono9pt7b 4 | #define FF2 FreeMono12pt7b 5 | #define FF3 FreeMono18pt7b 6 | #define FF4 FreeMono24pt7b 7 | 8 | #define FF5 FreeMonoBold9pt7b 9 | #define FF6 FreeMonoBold12pt7b 10 | #define FF7 FreeMonoBold18pt7b 11 | #define FF8 FreeMonoBold24pt7b 12 | 13 | #define FF9 FreeMonoBoldOblique9pt7b 14 | #define FF10 FreeMonoBoldOblique12pt7b 15 | #define FF11 FreeMonoBoldOblique18pt7b 16 | #define FF12 FreeMonoBoldOblique24pt7b 17 | 18 | #define FF13 FreeMonoOblique9pt7b 19 | #define FF14 FreeMonoOblique12pt7b 20 | #define FF15 FreeMonoOblique18pt7b 21 | #define FF16 FreeMonoOblique24pt7b 22 | 23 | #define FF17 FreeSans9pt7b 24 | #define FF18 FreeSans12pt7b 25 | #define FF19 FreeSans18pt7b 26 | #define FF20 FreeSans24pt7b 27 | 28 | #define FF21 FreeSansBold9pt7b 29 | #define FF22 FreeSansBold12pt7b 30 | #define FF23 FreeSansBold18pt7b 31 | #define FF24 FreeSansBold24pt7b 32 | 33 | #define FF25 FreeSansBoldOblique9pt7b 34 | #define FF26 FreeSansBoldOblique12pt7b 35 | #define FF27 FreeSansBoldOblique18pt7b 36 | #define FF28 FreeSansBoldOblique24pt7b 37 | 38 | #define FF29 FreeSansOblique9pt7b 39 | #define FF30 FreeSansOblique12pt7b 40 | #define FF31 FreeSansOblique18pt7b 41 | #define FF32 FreeSansOblique24pt7b 42 | 43 | #define FF33 FreeSerif9pt7b 44 | #define FF34 FreeSerif12pt7b 45 | #define FF35 FreeSerif18pt7b 46 | #define FF36 FreeSerif24pt7b 47 | 48 | #define FF37 FreeSerifBold9pt7b 49 | #define FF38 FreeSerifBold12pt7b 50 | #define FF39 FreeSerifBold18pt7b 51 | #define FF40 FreeSerifBold24pt7b 52 | 53 | #define FF41 FreeSerifBoldItalic9pt7b 54 | #define FF42 FreeSerifBoldItalic12pt7b 55 | #define FF43 FreeSerifBoldItalic18pt7b 56 | #define FF44 FreeSerifBoldItalic24pt7b 57 | 58 | #define FF45 FreeSerifItalic9pt7b 59 | #define FF46 FreeSerifItalic12pt7b 60 | #define FF47 FreeSerifItalic18pt7b 61 | #define FF48 FreeSerifItalic24pt7b 62 | -------------------------------------------------------------------------------- /lib/src/M5Stack.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) M5Stack. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | #include "M5Stack.h" 5 | 6 | M5Stack::M5Stack() : isInited(0) { 7 | } 8 | 9 | void M5Stack::begin(bool LCDEnable, bool SDEnable, bool SerialEnable, bool I2CEnable) { 10 | // Correct init once 11 | if (isInited == true) { 12 | return; 13 | } else { 14 | isInited = true; 15 | } 16 | 17 | // UART 18 | if (SerialEnable == true) { 19 | Serial.begin(115200); 20 | Serial.flush(); 21 | delay(50); 22 | Serial.print("M5Stack initializing..."); 23 | } 24 | 25 | // LCD INIT 26 | if (LCDEnable == true) { 27 | Lcd.begin(); 28 | } 29 | 30 | // TF Card 31 | if (SDEnable == true) { 32 | SD.begin(TFCARD_CS_PIN, SPI, 40000000); 33 | } 34 | 35 | // TONE 36 | // Speaker.begin(); 37 | 38 | // Set wakeup button 39 | Power.setWakeupButton(BUTTON_A_PIN); 40 | 41 | // I2C init 42 | if (I2CEnable == true) { 43 | Wire.begin(21, 22); 44 | } 45 | 46 | if (SerialEnable == true) { 47 | Serial.println("OK"); 48 | } 49 | } 50 | 51 | void M5Stack::update() { 52 | //Button update 53 | BtnA.read(); 54 | BtnB.read(); 55 | BtnC.read(); 56 | 57 | //Speaker update 58 | Speaker.update(); 59 | } 60 | 61 | /** 62 | * Function has been move to Power class.(for compatibility) 63 | * This name will be removed in a future release. 64 | */ 65 | void M5Stack::setPowerBoostKeepOn(bool en) { 66 | M5.Power.setPowerBoostKeepOn(en); 67 | } 68 | /** 69 | * Function has been move to Power class.(for compatibility) 70 | * This name will be removed in a future release. 71 | */ 72 | void M5Stack::setWakeupButton(uint8_t button) { 73 | M5.Power.setWakeupButton(button); 74 | } 75 | /** 76 | * Function has been move to Power class.(for compatibility) 77 | * This name will be removed in a future release. 78 | */ 79 | void M5Stack::powerOFF() { 80 | M5.Power.deepSleep(); 81 | } 82 | 83 | M5Stack M5; 84 | -------------------------------------------------------------------------------- /lib/src/utility/Speaker.cpp: -------------------------------------------------------------------------------- 1 | #include "Speaker.h" 2 | 3 | SPEAKER::SPEAKER(void) { 4 | _volume = 8; 5 | _begun = false; 6 | } 7 | 8 | void SPEAKER::begin() { 9 | _begun = true; 10 | ledcSetup(TONE_PIN_CHANNEL, 0, 13); 11 | ledcAttachPin(SPEAKER_PIN, TONE_PIN_CHANNEL); 12 | setBeep(1000, 100); 13 | } 14 | 15 | void SPEAKER::end() { 16 | mute(); 17 | ledcDetachPin(SPEAKER_PIN); 18 | _begun = false; 19 | } 20 | 21 | void SPEAKER::tone(uint16_t frequency) { 22 | if(!_begun) begin(); 23 | ledcWriteTone(TONE_PIN_CHANNEL, frequency); 24 | } 25 | 26 | void SPEAKER::tone(uint16_t frequency, uint32_t duration) { 27 | tone(frequency); 28 | _count = millis() + duration; 29 | speaker_on = 1; 30 | } 31 | 32 | void SPEAKER::beep() { 33 | if(!_begun) begin(); 34 | tone(_beep_freq, _beep_duration); 35 | } 36 | 37 | void SPEAKER::setBeep(uint16_t frequency, uint16_t duration) { 38 | _beep_freq = frequency; 39 | _beep_duration = duration; 40 | } 41 | 42 | void SPEAKER::setVolume(uint8_t volume) { 43 | _volume = 11 - volume; 44 | } 45 | 46 | void SPEAKER::mute() { 47 | ledcWriteTone(TONE_PIN_CHANNEL, 0); 48 | digitalWrite(SPEAKER_PIN, 0); 49 | } 50 | 51 | void SPEAKER::update() { 52 | if(speaker_on) { 53 | if(millis() > _count) { 54 | speaker_on = 0; 55 | mute(); 56 | } 57 | } 58 | } 59 | 60 | void SPEAKER::write(uint8_t value) { 61 | dacWrite(SPEAKER_PIN, value); 62 | } 63 | 64 | void SPEAKER::playMusic(const uint8_t* music_data, uint16_t sample_rate) { 65 | uint32_t length = strlen((char*)music_data); 66 | uint16_t delay_interval = ((uint32_t)1000000 / sample_rate); 67 | if(_volume != 11) { 68 | for(int i = 0; i < length; i++) { 69 | dacWrite(SPEAKER_PIN, music_data[i] / _volume); 70 | delayMicroseconds(delay_interval); 71 | } 72 | 73 | for(int t = music_data[length - 1] / _volume; t >= 0; t--) { 74 | dacWrite(SPEAKER_PIN, t); 75 | delay(2); 76 | } 77 | } 78 | // ledcSetup(TONE_PIN_CHANNEL, 0, 13); 79 | ledcAttachPin(SPEAKER_PIN, TONE_PIN_CHANNEL); 80 | } 81 | -------------------------------------------------------------------------------- /lib/src/utility/SH200Q.h: -------------------------------------------------------------------------------- 1 | #ifndef _SH200Q_H_ 2 | #define _SH200Q_H_ 3 | 4 | #include 5 | #include 6 | 7 | #define SH200I_ADDRESS 0x6C //7bit i2c address 8 | #define SH200I_WHOAMI 0x30 9 | #define SH200I_ACC_CONFIG 0x0E 10 | #define SH200I_GYRO_CONFIG 0x0F 11 | #define SH200I_GYRO_DLPF 0x11 12 | #define SH200I_FIFO_CONFIG 0x12 13 | #define SH200I_ACC_RANGE 0x16 14 | #define SH200I_GYRO_RANGE 0x2B 15 | #define SH200I_OUTPUT_ACC 0x00 16 | #define SH200I_OUTPUT_GYRO 0x06 17 | #define SH200I_OUTPUT_TEMP 0x0C 18 | #define SH200I_REG_SET1 0xBA 19 | #define SH200I_REG_SET2 0xCA //ADC reset 20 | #define SH200I_ADC_RESET 0xC2 //drive reset 21 | #define SH200I_SOFT_RESET 0x7F 22 | #define SH200I_RESET 0x75 23 | 24 | //#define G (9.8) 25 | #define RtA 57.324841 26 | #define AtR 0.0174533 27 | #define Gyro_Gr 0.0010653 28 | 29 | class SH200Q { 30 | public: 31 | enum Ascale { 32 | AFS_4G = 0, 33 | AFS_8G, 34 | AFS_16G 35 | }; 36 | 37 | enum Gscale { 38 | GFS_2000DPS = 0, 39 | GFS_1000DPS, 40 | GFS_500DPS, 41 | GFS_250DPS, 42 | GFS_125DPS, 43 | }; 44 | 45 | 46 | 47 | public: 48 | SH200Q(); 49 | 50 | int Init(void); 51 | 52 | void getAccelAdc(int16_t* ax, int16_t* ay, int16_t* az); 53 | void getGyroAdc(int16_t* gx, int16_t* gy, int16_t* gz); 54 | void getTempAdc(int16_t *t); 55 | 56 | void getAccelData(float* ax, float* ay, float* az); 57 | void getGyroData(float* gx, float* gy, float* gz); 58 | void getTempData(float *t); 59 | void getAhrsData(float *pitch,float *roll,float *yaw); 60 | 61 | void setGyroFsr(Gscale scale); 62 | void setAccelFsr(Ascale scale); 63 | 64 | public: 65 | float aRes, gRes; 66 | uint8_t imuId; 67 | Gscale Gyscale; 68 | Ascale Acscale; 69 | 70 | protected: 71 | void I2C_Read_NBytes(uint8_t driver_Addr, uint8_t start_Addr, uint8_t number_Bytes, uint8_t *read_Buffer); 72 | void I2C_Write_NBytes(uint8_t driver_Addr, uint8_t start_Addr, uint8_t number_Bytes, uint8_t *write_Buffer); 73 | void sh200i_ADCReset(void); 74 | void sh200i_Reset(void); 75 | void updateGres(); 76 | void updateAres(); 77 | }; 78 | #endif -------------------------------------------------------------------------------- /lib/src/utility/Button.h: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------------------* 2 | * Arduino Button Library v1.0 * 3 | * Jack Christensen Mar 2012 * 4 | * * 5 | * This work is licensed under the Creative Commons Attribution- * 6 | * ShareAlike 3.0 Unported License. To view a copy of this license, * 7 | * visit http://creativecommons.org/licenses/by-sa/3.0/ or send a * 8 | * letter to Creative Commons, 171 Second Street, Suite 300, * 9 | * San Francisco, California, 94105, USA. * 10 | *----------------------------------------------------------------------*/ 11 | #ifndef Button_h 12 | #define Button_h 13 | // #if ARDUINO >= 100 14 | #include 15 | // #else 16 | // #include 17 | // #endif 18 | class Button { 19 | public: 20 | Button(uint8_t pin, uint8_t invert, uint32_t dbTime); 21 | uint8_t read(); 22 | uint8_t isPressed(); 23 | uint8_t isReleased(); 24 | uint8_t wasPressed(); 25 | uint8_t wasReleased(); 26 | uint8_t pressedFor(uint32_t ms); 27 | uint8_t releasedFor(uint32_t ms); 28 | uint8_t wasReleasefor(uint32_t ms); 29 | uint32_t lastChange(); 30 | 31 | private: 32 | uint8_t _pin; //arduino pin number 33 | uint8_t _puEnable; //internal pullup resistor enabled 34 | uint8_t _invert; //if 0, interpret high state as pressed, else interpret low state as pressed 35 | uint8_t _state; //current button state 36 | uint8_t _lastState; //previous button state 37 | uint8_t _changed; //state changed since last read 38 | uint32_t _time; //time of current state (all times are in ms) 39 | uint32_t _lastTime; //time of previous state 40 | uint32_t _lastChange; //time of last state change 41 | uint32_t _dbTime; //debounce time 42 | uint32_t _pressTime; //press time 43 | uint32_t _hold_time; //hold time call wasreleasefor 44 | }; 45 | #endif 46 | -------------------------------------------------------------------------------- /lib/src/utility/ILI9341_Rotation.h: -------------------------------------------------------------------------------- 1 | 2 | // This is the command sequence that rotates the ILI9341 driver coordinate frame 3 | 4 | rotation = m % 8; // Limit the range of values to 0-7 5 | 6 | writecommand(TFT_MADCTL); 7 | switch (rotation) { 8 | case 0: 9 | #ifdef M5STACK 10 | writedata(TFT_MAD_MY | TFT_MAD_MV | TFT_MAD_BGR); 11 | #else 12 | writedata(TFT_MAD_MX | TFT_MAD_BGR); 13 | #endif 14 | _width = _init_width; 15 | _height = _init_height; 16 | break; 17 | case 1: 18 | #ifdef M5STACK 19 | writedata(TFT_MAD_BGR); 20 | #else 21 | writedata(TFT_MAD_MV | TFT_MAD_BGR); 22 | #endif 23 | _width = _init_height; 24 | _height = _init_width; 25 | break; 26 | case 2: 27 | #ifdef M5STACK 28 | writedata(TFT_MAD_MV | TFT_MAD_MX | TFT_MAD_BGR); 29 | #else 30 | writedata(TFT_MAD_MY | TFT_MAD_BGR); 31 | #endif 32 | _width = _init_width; 33 | _height = _init_height; 34 | break; 35 | case 3: 36 | #ifdef M5STACK 37 | writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_BGR); 38 | #else 39 | writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_MV | TFT_MAD_BGR); 40 | #endif 41 | _width = _init_height; 42 | _height = _init_width; 43 | break; 44 | // These next rotations are for bottom up BMP drawing 45 | case 4: 46 | #ifdef M5STACK 47 | writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_MV | TFT_MAD_BGR); 48 | #else 49 | writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_BGR); 50 | #endif 51 | _width = _init_width; 52 | _height = _init_height; 53 | break; 54 | case 5: 55 | #ifdef M5STACK 56 | writedata(TFT_MAD_MY | TFT_MAD_BGR); 57 | #else 58 | writedata(TFT_MAD_MV | TFT_MAD_MX | TFT_MAD_BGR); 59 | #endif 60 | _width = _init_height; 61 | _height = _init_width; 62 | break; 63 | case 6: 64 | #ifdef M5STACK 65 | writedata(TFT_MAD_MV | TFT_MAD_BGR); 66 | #else 67 | writedata(TFT_MAD_BGR); 68 | #endif 69 | _width = _init_width; 70 | _height = _init_height; 71 | break; 72 | case 7: 73 | #ifdef M5STACK 74 | writedata(TFT_MAD_MX | TFT_MAD_BGR); 75 | #else 76 | writedata(TFT_MAD_MY | TFT_MAD_MV | TFT_MAD_BGR); 77 | #endif 78 | _width = _init_height; 79 | _height = _init_width; 80 | break; 81 | 82 | } 83 | -------------------------------------------------------------------------------- /lib/src/utility/Power.h: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------------------* 2 | * M5Stack Bettery/Power Control Library v1.0 * 3 | * * 4 | * This work is licensed under the GNU Lesser General Public * 5 | * License v2.1 * 6 | * https://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html * 7 | *----------------------------------------------------------------------*/ 8 | #ifndef Power_h 9 | #define Power_h 10 | #include 11 | #include 12 | 13 | #define SLEEP_MSEC(us) (((uint64_t)us) * 1000L) 14 | #define SLEEP_SEC(us) (((uint64_t)us) * 1000000L) 15 | #define SLEEP_MIN(us) (((uint64_t)us) * 60L * 1000000L) 16 | #define SLEEP_HR(us) (((uint64_t)us) * 60L * 60L * 1000000L) 17 | 18 | class POWER 19 | { 20 | public: 21 | POWER(); 22 | bool canControl(); 23 | void begin(); 24 | 25 | // -- ShutdownTimeParam 26 | enum ShutdownTime 27 | { 28 | SHUTDOWN_8S = 0, 29 | SHUTDOWN_16S, 30 | SHUTDOWN_32S, 31 | SHUTDOWN_64S 32 | }; 33 | 34 | // -- control for power 35 | bool setKeepLightLoad(bool en) __attribute__((deprecated)); 36 | bool setPowerBoostKeepOn(bool en); 37 | bool setAutoBootOnLoad(bool en); 38 | bool setLowPowerShutdown(bool en) __attribute__((deprecated)); 39 | bool setLowPowerShutdownTime(ShutdownTime time); 40 | bool setPowerBoostOnOff(bool en); 41 | bool setPowerBoostSet(bool en); 42 | bool setPowerVin(bool en); 43 | bool setPowerWLEDSet(bool en); 44 | bool setPowerBtnEn(bool en); 45 | 46 | // -- control for battery 47 | bool setVinMaxCurrent(uint8_t cur); 48 | bool setChargeVolt(uint8_t volt); 49 | 50 | bool setCharge(bool en); 51 | bool isChargeFull(); 52 | bool isCharging(); 53 | int8_t getBatteryLevel(); 54 | bool batteryMode(bool en); 55 | 56 | // -- configuration for wakeup 57 | void setWakeupButton(uint8_t button); 58 | 59 | // -- get resson for startup 60 | bool isResetbyWatchdog(); 61 | bool isResetbyDeepsleep(); 62 | bool isResetbySoftware(); 63 | bool isResetbyPowerSW(); 64 | 65 | // -- sleep 66 | void deepSleep(uint64_t time_in_us = 0); 67 | void lightSleep(uint64_t time_in_us = 0); 68 | 69 | // -- power off 70 | void powerOFF(); 71 | 72 | // -- software reset 73 | void reset(); 74 | 75 | private: 76 | uint8_t _wakeupPin; 77 | }; 78 | #endif 79 | -------------------------------------------------------------------------------- /lib/src/M5LoRa.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Sandeep Mistry. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | // 23FEB18 gojimmypi reversed LORA_DEFAULT_RESET_PIN and LORA_DEFAULT_DIO0_PIN pin numbers 5 | // reset on pin 36; irq on pin 26 6 | 7 | #ifndef M5LORA_H 8 | #define M5LORA_H 9 | 10 | #include 11 | #include 12 | 13 | #define LORA_DEFAULT_SS_PIN 5 14 | #define LORA_DEFAULT_RESET_PIN 36 15 | #define LORA_DEFAULT_DIO0_PIN 26 16 | 17 | #define PA_OUTPUT_RFO_PIN 0 18 | #define PA_OUTPUT_PA_BOOST_PIN 1 19 | 20 | class LoRaClass : public Stream { 21 | public: 22 | LoRaClass(); 23 | 24 | int begin(long frequency); 25 | void end(); 26 | 27 | int beginPacket(int implicitHeader = false); 28 | int endPacket(); 29 | 30 | int parsePacket(int size = 0); 31 | int packetRssi(); 32 | float packetSnr(); 33 | 34 | // from Print 35 | virtual size_t write(uint8_t byte); 36 | virtual size_t write(const uint8_t *buffer, size_t size); 37 | 38 | // from Stream 39 | virtual int available(); 40 | virtual int read(); 41 | virtual int peek(); 42 | virtual void flush(); 43 | 44 | void onReceive(void(*callback)(int)); 45 | 46 | void receive(int size = 0); 47 | void idle(); 48 | void sleep(); 49 | 50 | void setTxPower(int level, int outputPin = PA_OUTPUT_PA_BOOST_PIN); 51 | void setFrequency(long frequency); 52 | void setSpreadingFactor(int sf); 53 | void setSignalBandwidth(long sbw); 54 | void setCodingRate4(int denominator); 55 | void setPreambleLength(long length); 56 | void setSyncWord(int sw); 57 | void enableCrc(); 58 | void disableCrc(); 59 | 60 | // deprecated 61 | void crc() { enableCrc(); } 62 | void noCrc() { disableCrc(); } 63 | 64 | byte random(); 65 | 66 | void setPins(int ss = LORA_DEFAULT_SS_PIN, int reset = LORA_DEFAULT_RESET_PIN, int dio0 = LORA_DEFAULT_DIO0_PIN); 67 | void setSPIFrequency(uint32_t frequency); 68 | 69 | void dumpRegisters(Stream& out); 70 | 71 | private: 72 | void explicitHeaderMode(); 73 | void implicitHeaderMode(); 74 | 75 | void handleDio0Rise(); 76 | 77 | uint8_t readRegister(uint8_t address); 78 | void writeRegister(uint8_t address, uint8_t value); 79 | uint8_t singleTransfer(uint8_t address, uint8_t value); 80 | 81 | static void onDio0Rise(); 82 | 83 | private: 84 | SPISettings _spiSettings; 85 | int _ss; 86 | int _reset; 87 | int _dio0; 88 | int _frequency; 89 | int _packetIndex; 90 | int _implicitHeaderMode; 91 | void (*_onReceive)(int); 92 | }; 93 | 94 | extern LoRaClass LoRa; 95 | 96 | #endif 97 | -------------------------------------------------------------------------------- /lib/src/utility/qrcode.h: -------------------------------------------------------------------------------- 1 | /** 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2017 Richard Moore 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | 25 | /** 26 | * Special thanks to Nayuki (https://www.nayuki.io/) from which this library was 27 | * heavily inspired and compared against. 28 | * 29 | * See: https://github.com/nayuki/QR-Code-generator/tree/master/cpp 30 | */ 31 | 32 | 33 | #ifndef __QRCODE_H_ 34 | #define __QRCODE_H_ 35 | 36 | #ifndef __cplusplus 37 | typedef unsigned char bool; 38 | static const bool false = 0; 39 | static const bool true = 1; 40 | #endif 41 | 42 | #include 43 | 44 | 45 | // QR Code Format Encoding 46 | #define MODE_NUMERIC 0 47 | #define MODE_ALPHANUMERIC 1 48 | #define MODE_BYTE 2 49 | 50 | 51 | // Error Correction Code Levels 52 | #define ECC_LOW 0 53 | #define ECC_MEDIUM 1 54 | #define ECC_QUARTILE 2 55 | #define ECC_HIGH 3 56 | 57 | 58 | // If set to non-zero, this library can ONLY produce QR codes at that version 59 | // This saves a lot of dynamic memory, as the codeword tables are skipped 60 | #ifndef LOCK_VERSION 61 | #define LOCK_VERSION 0 62 | #endif 63 | 64 | 65 | typedef struct QRCode { 66 | uint8_t version; 67 | uint8_t size; 68 | uint8_t ecc; 69 | uint8_t mode; 70 | uint8_t mask; 71 | uint8_t *modules; 72 | } QRCode; 73 | 74 | 75 | #ifdef __cplusplus 76 | extern "C"{ 77 | #endif /* __cplusplus */ 78 | 79 | 80 | 81 | uint16_t qrcode_getBufferSize(uint8_t version); 82 | 83 | int8_t qrcode_initText(QRCode *qrcode, uint8_t *modules, uint8_t version, uint8_t ecc, const char *data); 84 | int8_t qrcode_initBytes(QRCode *qrcode, uint8_t *modules, uint8_t version, uint8_t ecc, uint8_t *data, uint16_t length); 85 | 86 | bool qrcode_getModule(QRCode *qrcode, uint8_t x, uint8_t y); 87 | 88 | 89 | 90 | #ifdef __cplusplus 91 | } 92 | #endif /* __cplusplus */ 93 | 94 | 95 | #endif /* __QRCODE_H_ */ 96 | -------------------------------------------------------------------------------- /lib/src/utility/MPU6886.h: -------------------------------------------------------------------------------- 1 | /* 2 | Note: The MPU6886 is an I2C sensor and uses the Arduino Wire library. 3 | Because the sensor is not 5V tolerant, we are using a 3.3 V 8 MHz Pro Mini or 4 | a 3.3 V Teensy 3.1. We have disabled the internal pull-ups used by the Wire 5 | library in the Wire.h/twi.c utility file. We are also using the 400 kHz fast 6 | I2C mode by setting the TWI_FREQ to 400000L /twi.h utility file. 7 | */ 8 | #ifndef _MPU6886_H_ 9 | #define _MPU6886_H_ 10 | 11 | #include 12 | #include 13 | 14 | #define MPU6886_ADDRESS 0x68 15 | #define MPU6886_WHOAMI 0x75 16 | #define MPU6886_ACCEL_INTEL_CTRL 0x69 17 | #define MPU6886_SMPLRT_DIV 0x19 18 | #define MPU6886_INT_PIN_CFG 0x37 19 | #define MPU6886_INT_ENABLE 0x38 20 | #define MPU6886_ACCEL_XOUT_H 0x3B 21 | #define MPU6886_ACCEL_XOUT_L 0x3C 22 | #define MPU6886_ACCEL_YOUT_H 0x3D 23 | #define MPU6886_ACCEL_YOUT_L 0x3E 24 | #define MPU6886_ACCEL_ZOUT_H 0x3F 25 | #define MPU6886_ACCEL_ZOUT_L 0x40 26 | 27 | #define MPU6886_TEMP_OUT_H 0x41 28 | #define MPU6886_TEMP_OUT_L 0x42 29 | 30 | #define MPU6886_GYRO_XOUT_H 0x43 31 | #define MPU6886_GYRO_XOUT_L 0x44 32 | #define MPU6886_GYRO_YOUT_H 0x45 33 | #define MPU6886_GYRO_YOUT_L 0x46 34 | #define MPU6886_GYRO_ZOUT_H 0x47 35 | #define MPU6886_GYRO_ZOUT_L 0x48 36 | 37 | #define MPU6886_USER_CTRL 0x6A 38 | #define MPU6886_PWR_MGMT_1 0x6B 39 | #define MPU6886_PWR_MGMT_2 0x6C 40 | #define MPU6886_CONFIG 0x1A 41 | #define MPU6886_GYRO_CONFIG 0x1B 42 | #define MPU6886_ACCEL_CONFIG 0x1C 43 | #define MPU6886_ACCEL_CONFIG2 0x1D 44 | #define MPU6886_FIFO_EN 0x23 45 | 46 | //#define G (9.8) 47 | #define RtA 57.324841 48 | #define AtR 0.0174533 49 | #define Gyro_Gr 0.0010653 50 | 51 | class MPU6886 { 52 | public: 53 | enum Ascale { 54 | AFS_2G = 0, 55 | AFS_4G, 56 | AFS_8G, 57 | AFS_16G 58 | }; 59 | 60 | enum Gscale { 61 | GFS_250DPS = 0, 62 | GFS_500DPS, 63 | GFS_1000DPS, 64 | GFS_2000DPS 65 | }; 66 | 67 | 68 | 69 | public: 70 | MPU6886(); 71 | int Init(void); 72 | void getAccelAdc(int16_t* ax, int16_t* ay, int16_t* az); 73 | void getGyroAdc(int16_t* gx, int16_t* gy, int16_t* gz); 74 | void getTempAdc(int16_t *t); 75 | 76 | void getAccelData(float* ax, float* ay, float* az); 77 | void getGyroData(float* gx, float* gy, float* gz); 78 | void getTempData(float *t); 79 | 80 | void setGyroFsr(Gscale scale); 81 | void setAccelFsr(Ascale scale); 82 | 83 | void getAhrsData(float *pitch,float *roll,float *yaw); 84 | 85 | public: 86 | float aRes, gRes, imuId; 87 | Gscale Gyscale; 88 | Ascale Acscale; 89 | 90 | private: 91 | 92 | private: 93 | void I2C_Read_NBytes(uint8_t driver_Addr, uint8_t start_Addr, uint8_t number_Bytes, uint8_t *read_Buffer); 94 | void I2C_Write_NBytes(uint8_t driver_Addr, uint8_t start_Addr, uint8_t number_Bytes, uint8_t *write_Buffer); 95 | void updateGres(); 96 | void updateAres(); 97 | }; 98 | #endif -------------------------------------------------------------------------------- /lib/src/utility/ILI9341_Init.h: -------------------------------------------------------------------------------- 1 | 2 | // This is the command sequence that initialises the ILI9341 driver 3 | // 4 | // This setup information uses simple 8 bit SPI writecommand() and writedata() functions 5 | // 6 | // See ST7735_Setup.h file for an alternative format 7 | 8 | { 9 | writecommand(0xEF); 10 | writedata(0x03); 11 | writedata(0x80); 12 | writedata(0x02); 13 | 14 | writecommand(0xCF); 15 | writedata(0x00); 16 | writedata(0XC1); 17 | writedata(0X30); 18 | 19 | writecommand(0xED); 20 | writedata(0x64); 21 | writedata(0x03); 22 | writedata(0X12); 23 | writedata(0X81); 24 | 25 | writecommand(0xE8); 26 | writedata(0x85); 27 | writedata(0x00); 28 | writedata(0x78); 29 | 30 | writecommand(0xCB); 31 | writedata(0x39); 32 | writedata(0x2C); 33 | writedata(0x00); 34 | writedata(0x34); 35 | writedata(0x02); 36 | 37 | writecommand(0xF7); 38 | writedata(0x20); 39 | 40 | writecommand(0xEA); 41 | writedata(0x00); 42 | writedata(0x00); 43 | 44 | writecommand(ILI9341_PWCTR1); // Power control 45 | writedata(0x23); // VRH[5:0] 46 | 47 | writecommand(ILI9341_PWCTR2); // Power control 48 | writedata(0x10); // SAP[2:0];BT[3:0] 49 | 50 | writecommand(ILI9341_VMCTR1); // VCM control 51 | writedata(0x3e); 52 | writedata(0x28); 53 | 54 | writecommand(ILI9341_VMCTR2); // VCM control2 55 | writedata(0x86); // -- 56 | 57 | writecommand(ILI9341_MADCTL); // Memory Access Control 58 | #ifdef M5STACK 59 | writedata(0xA8); // Rotation 0 (portrait mode) 60 | #else 61 | writedata(0x48); // Rotation 0 (portrait mode) 62 | #endif 63 | 64 | writecommand(ILI9341_PIXFMT); 65 | writedata(0x55); 66 | 67 | writecommand(ILI9341_FRMCTR1); 68 | writedata(0x00); 69 | writedata(0x13); // 0x18 79Hz, 0x1B default 70Hz, 0x13 100Hz 70 | 71 | writecommand(ILI9341_DFUNCTR); // Display Function Control 72 | writedata(0x08); 73 | writedata(0x82); 74 | writedata(0x27); 75 | 76 | writecommand(0xF2); // 3Gamma Function Disable 77 | writedata(0x00); 78 | 79 | writecommand(ILI9341_GAMMASET); // Gamma curve selected 80 | writedata(0x01); 81 | 82 | writecommand(ILI9341_GMCTRP1); // Set Gamma 83 | writedata(0x0F); 84 | writedata(0x31); 85 | writedata(0x2B); 86 | writedata(0x0C); 87 | writedata(0x0E); 88 | writedata(0x08); 89 | writedata(0x4E); 90 | writedata(0xF1); 91 | writedata(0x37); 92 | writedata(0x07); 93 | writedata(0x10); 94 | writedata(0x03); 95 | writedata(0x0E); 96 | writedata(0x09); 97 | writedata(0x00); 98 | 99 | writecommand(ILI9341_GMCTRN1); // Set Gamma 100 | writedata(0x00); 101 | writedata(0x0E); 102 | writedata(0x14); 103 | writedata(0x03); 104 | writedata(0x11); 105 | writedata(0x07); 106 | writedata(0x31); 107 | writedata(0xC1); 108 | writedata(0x48); 109 | writedata(0x08); 110 | writedata(0x0F); 111 | writedata(0x0C); 112 | writedata(0x31); 113 | writedata(0x36); 114 | writedata(0x0F); 115 | 116 | writecommand(ILI9341_SLPOUT); // Exit Sleep 117 | 118 | spi_end(); 119 | delay(120); 120 | spi_begin(); 121 | 122 | writecommand(ILI9341_DISPON); // Display on 123 | } 124 | -------------------------------------------------------------------------------- /lib/src/utility/pngle.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * MIT License 3 | * 4 | * Copyright (c) 2019 kikuchan 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #ifndef __PNGLE_H__ 26 | #define __PNGLE_H__ 27 | 28 | #include 29 | 30 | #ifdef __cplusplus 31 | extern "C" { 32 | #endif 33 | 34 | // Main Pngle object 35 | typedef struct _pngle_t pngle_t; 36 | 37 | // Callback signatures 38 | typedef void (*pngle_init_callback_t)(pngle_t *pngle, uint32_t w, uint32_t h); 39 | typedef void (*pngle_draw_callback_t)(pngle_t *pngle, uint32_t x, uint32_t y, uint32_t w, uint32_t h, uint8_t rgba[4]); 40 | typedef void (*pngle_done_callback_t)(pngle_t *pngle); 41 | 42 | // ---------------- 43 | // Basic interfaces 44 | // ---------------- 45 | pngle_t *pngle_new(); 46 | void pngle_destroy(pngle_t *pngle); 47 | void pngle_reset(pngle_t *pngle); // clear its internal state (not applied to pngle_set_* functions) 48 | const char *pngle_error(pngle_t *pngle); 49 | int pngle_feed(pngle_t *pngle, const void *buf, size_t len); // returns -1: On error, 0: Need more data, n: n bytes eaten 50 | 51 | uint32_t pngle_get_width(pngle_t *pngle); 52 | uint32_t pngle_get_height(pngle_t *pngle); 53 | 54 | void pngle_set_init_callback(pngle_t *png, pngle_init_callback_t callback); 55 | void pngle_set_draw_callback(pngle_t *png, pngle_draw_callback_t callback); 56 | void pngle_set_done_callback(pngle_t *png, pngle_done_callback_t callback); 57 | 58 | void pngle_set_display_gamma(pngle_t *pngle, double display_gamma); // enables gamma correction by specifying display gamma, typically 2.2. No effect when gAMA chunk is missing 59 | 60 | void pngle_set_user_data(pngle_t *pngle, void *user_data); 61 | void *pngle_get_user_data(pngle_t *pngle); 62 | 63 | 64 | // ---------------- 65 | // Debug interfaces 66 | // ---------------- 67 | 68 | typedef struct _pngle_ihdr_t { 69 | uint32_t width; 70 | uint32_t height; 71 | uint8_t depth; 72 | uint8_t color_type; 73 | uint8_t compression; 74 | uint8_t filter; 75 | uint8_t interlace; 76 | } pngle_ihdr_t; 77 | 78 | // Get IHDR information 79 | pngle_ihdr_t *pngle_get_ihdr(pngle_t *pngle); 80 | 81 | 82 | #ifdef __cplusplus 83 | } 84 | #endif 85 | 86 | #endif /* __PNGLE_H__ */ 87 | -------------------------------------------------------------------------------- /lib/src/utility/M5Timer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * M5Timer.h 3 | * 4 | * M5Timer - A timer library for Arduino. 5 | * Author: mromani@ottotecnica.com 6 | * Copyright (c) 2010 OTTOTECNICA Italy 7 | * 8 | * This library is free software; you can redistribute it 9 | * and/or modify it under the terms of the GNU Lesser 10 | * General Public License as published by the Free Software 11 | * Foundation; either version 2.1 of the License, or (at 12 | * your option) any later version. 13 | * 14 | * This library is distributed in the hope that it will 15 | * be useful, but WITHOUT ANY WARRANTY; without even the 16 | * implied warranty of MERCHANTABILITY or FITNESS FOR A 17 | * PARTICULAR PURPOSE. See the GNU Lesser General Public 18 | * License for more details. 19 | * 20 | * You should have received a copy of the GNU Lesser 21 | * General Public License along with this library; if not, 22 | * write to the Free Software Foundation, Inc., 23 | * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 24 | * 25 | */ 26 | 27 | 28 | #ifndef M5Timer_H 29 | #define M5Timer_H 30 | 31 | #include 32 | #include 33 | 34 | typedef std::function timer_callback; 35 | 36 | class M5Timer { 37 | public: 38 | // maximum number of timers 39 | const static int MAX_TIMERS = 10; 40 | 41 | // setTimer() constants 42 | const static int RUN_FOREVER = 0; 43 | const static int RUN_ONCE = 1; 44 | 45 | // constructor 46 | M5Timer(); 47 | 48 | // this function must be called inside loop() 49 | void run(); 50 | 51 | // call function f every d milliseconds 52 | int setInterval(long d, timer_callback f); 53 | 54 | // call function f once after d milliseconds 55 | int setTimeout(long d, timer_callback f); 56 | 57 | // call function f every d milliseconds for n times 58 | int setTimer(long d, timer_callback f, int n); 59 | 60 | // destroy the specified timer 61 | void deleteTimer(int numTimer); 62 | 63 | // restart the specified timer 64 | void restartTimer(int numTimer); 65 | 66 | // returns true if the specified timer is enabled 67 | boolean isEnabled(int numTimer); 68 | 69 | // enables the specified timer 70 | void enable(int numTimer); 71 | 72 | // disables the specified timer 73 | void disable(int numTimer); 74 | 75 | // enables the specified timer if it's currently disabled, 76 | // and vice-versa 77 | void toggle(int numTimer); 78 | 79 | // returns the number of used timers 80 | int getNumTimers(); 81 | 82 | // returns the number of available timers 83 | int getNumAvailableTimers() { return MAX_TIMERS - numTimers; }; 84 | 85 | private: 86 | // deferred call constants 87 | const static int DEFCALL_DONTRUN = 0; // don't call the callback function 88 | const static int DEFCALL_RUNONLY = 1; // call the callback function but don't delete the timer 89 | const static int DEFCALL_RUNANDDEL = 2; // call the callback function and delete the timer 90 | 91 | // find the first available slot 92 | int findFirstFreeSlot(); 93 | 94 | // value returned by the millis() function 95 | // in the previous run() call 96 | unsigned long prev_millis[MAX_TIMERS]; 97 | 98 | // pointers to the callback functions 99 | timer_callback callbacks[MAX_TIMERS]; 100 | 101 | // delay values 102 | long delays[MAX_TIMERS]; 103 | 104 | // number of runs to be executed for each timer 105 | int maxNumRuns[MAX_TIMERS]; 106 | 107 | // number of executed runs for each timer 108 | int numRuns[MAX_TIMERS]; 109 | 110 | // which timers are enabled 111 | boolean enabled[MAX_TIMERS]; 112 | 113 | // deferred function call (sort of) - N.B.: this array is only used in run() 114 | int toBeCalled[MAX_TIMERS]; 115 | 116 | // actual number of timers in use 117 | int numTimers; 118 | }; 119 | 120 | #endif 121 | -------------------------------------------------------------------------------- /lib/src/M5Display.h: -------------------------------------------------------------------------------- 1 | #ifndef _M5DISPLAY_H_ 2 | #define _M5DISPLAY_H_ 3 | 4 | #include 5 | #include 6 | #include 7 | #include "utility/In_eSPI.h" 8 | #include "utility/Sprite.h" 9 | 10 | typedef enum { 11 | JPEG_DIV_NONE, 12 | JPEG_DIV_2, 13 | JPEG_DIV_4, 14 | JPEG_DIV_8, 15 | JPEG_DIV_MAX 16 | } jpeg_div_t; 17 | 18 | class M5Display : public TFT_eSPI { 19 | public: 20 | M5Display(); 21 | void begin(); 22 | void sleep(); 23 | void wakeup(); 24 | void setBrightness(uint8_t brightness); 25 | void clearDisplay(uint32_t color=ILI9341_BLACK) { fillScreen(color); } 26 | void clear(uint32_t color=ILI9341_BLACK) { fillScreen(color); } 27 | void display() {} 28 | 29 | inline void startWrite(void){ 30 | #if defined (SPI_HAS_TRANSACTION) && defined (SUPPORT_TRANSACTIONS) && !defined(ESP32_PARALLEL) 31 | if (locked) { 32 | locked = false; SPI.beginTransaction(SPISettings(SPI_FREQUENCY, MSBFIRST, SPI_MODE0)); 33 | } 34 | #endif 35 | CS_L; 36 | } 37 | inline void endWrite(void){ 38 | #if defined (SPI_HAS_TRANSACTION) && defined (SUPPORT_TRANSACTIONS) && !defined(ESP32_PARALLEL) 39 | if(!inTransaction) { 40 | if (!locked) { 41 | locked = true; 42 | SPI.endTransaction(); 43 | } 44 | } 45 | #endif 46 | CS_H; 47 | } 48 | inline void writePixel(uint16_t color) { 49 | SPI.write16(color); 50 | } 51 | inline void writePixels(uint16_t * colors, uint32_t len){ 52 | SPI.writePixels((uint8_t*)colors , len * 2); 53 | } 54 | void progressBar(int x, int y, int w, int h, uint8_t val); 55 | 56 | #define setFont setFreeFont 57 | 58 | void qrcode(const char *string, uint16_t x = 50, uint16_t y = 10, uint8_t width = 220, uint8_t version = 6); 59 | void qrcode(const String &string, uint16_t x = 50, uint16_t y = 10, uint8_t width = 220, uint8_t version = 6); 60 | 61 | void drawBmp(fs::FS &fs, const char *path, uint16_t x, uint16_t y); 62 | void drawBmpFile(fs::FS &fs, const char *path, uint16_t x, uint16_t y); 63 | 64 | void drawBitmap(int16_t x0, int16_t y0, int16_t w, int16_t h, const uint16_t *data); 65 | void drawBitmap(int16_t x0, int16_t y0, int16_t w, int16_t h, const uint8_t *data); 66 | void drawBitmap(int16_t x0, int16_t y0, int16_t w, int16_t h, uint16_t *data); 67 | void drawBitmap(int16_t x0, int16_t y0, int16_t w, int16_t h, uint8_t *data); 68 | void drawBitmap(int16_t x0, int16_t y0, int16_t w, int16_t h, const uint16_t *data, uint16_t transparent); 69 | 70 | void drawJpg(const uint8_t *jpg_data, size_t jpg_len, uint16_t x = 0, 71 | uint16_t y = 0, uint16_t maxWidth = 0, uint16_t maxHeight = 0, 72 | uint16_t offX = 0, uint16_t offY = 0, 73 | jpeg_div_t scale = JPEG_DIV_NONE); 74 | 75 | void drawJpg(fs::FS &fs, const char *path, uint16_t x = 0, uint16_t y = 0, 76 | uint16_t maxWidth = 0, uint16_t maxHeight = 0, 77 | uint16_t offX = 0, uint16_t offY = 0, 78 | jpeg_div_t scale = JPEG_DIV_NONE); 79 | 80 | void drawJpgFile(fs::FS &fs, const char *path, uint16_t x = 0, uint16_t y = 0, 81 | uint16_t maxWidth = 0, uint16_t maxHeight = 0, 82 | uint16_t offX = 0, uint16_t offY = 0, 83 | jpeg_div_t scale = JPEG_DIV_NONE); 84 | 85 | void drawPngFile(fs::FS &fs, const char *path, uint16_t x = 0, uint16_t y = 0, 86 | uint16_t maxWidth = 0, uint16_t maxHeight = 0, 87 | uint16_t offX = 0, uint16_t offY = 0, 88 | double scale = 1.0, uint8_t alphaThreshold = 127); 89 | 90 | void drawPngUrl(const char *url, uint16_t x = 0, uint16_t y = 0, 91 | uint16_t maxWidth = 0, uint16_t maxHeight = 0, 92 | uint16_t offX = 0, uint16_t offY = 0, 93 | double scale = 1.0, uint8_t alphaThreshold = 127); 94 | 95 | private: 96 | }; 97 | #endif 98 | -------------------------------------------------------------------------------- /src/simcom.cpp: -------------------------------------------------------------------------------- 1 | #include "simcom.h" 2 | 3 | void simcom::begin(HardwareSerial & uart,Print *stream) 4 | { 5 | _serialPtr = &uart; 6 | _serialPtr->setTimeout(1000); 7 | _log = stream; 8 | 9 | #ifdef LOG_ASYNC 10 | logQueue = xQueueCreate(32, sizeof(char*)); 11 | #endif 12 | } 13 | 14 | void simcom::sendCMD(String str) 15 | { 16 | _serialPtr->write(str.c_str()); 17 | } 18 | 19 | int simcom::sendCMDAndFindUntil(String str,std::initializer_list args,int retry,int max_line,int timeout) 20 | { 21 | int strlist_size = args.size(); 22 | if( strlist_size <= 0 ) return -1; 23 | 24 | String *strbuff = new String[strlist_size]; 25 | 26 | int cnt = 0; 27 | 28 | for( const String &item : args ) 29 | { 30 | strbuff[cnt] = item; 31 | cnt++; 32 | } 33 | 34 | _serialPtr->setTimeout(timeout); 35 | 36 | while (retry >= 0 ) 37 | { 38 | _serialPtr->write(str.c_str()); 39 | 40 | SIMCOM_LOG("[SEND]%s\r\n",str.c_str()); 41 | 42 | Serial.println(str.c_str()); 43 | 44 | int line_cnt = 0; 45 | 46 | while( line_cnt < max_line ) 47 | { 48 | String reviceStr = _serialPtr->readStringUntil('\n'); 49 | 50 | if( !reviceStr.isEmpty()) 51 | { 52 | reviceStr.replace("\r",""); reviceStr.replace("\n",""); reviceStr.trim(); 53 | if( reviceStr.length() >= 1 ) 54 | { 55 | SIMCOM_LOG("[REVC]%s\r\n",reviceStr.c_str()); 56 | 57 | for (int i = 0; i < strlist_size; i++) 58 | { 59 | if( reviceStr.indexOf(strbuff[i]) >= 0 ){ delete[] strbuff; return i; } 60 | } 61 | } 62 | } 63 | line_cnt++; 64 | } 65 | retry --; 66 | } 67 | delete[] strbuff; 68 | return -1; 69 | } 70 | 71 | int simcom::sendCMDAndWaitRevice(String str,std::initializer_list args,String reviceMark,String *revidePtr,int retry,int max_line,int timeout) 72 | { 73 | int strlist_size = args.size(); 74 | if( strlist_size <= 0 ) return -1; 75 | 76 | String *strbuff = new String[strlist_size]; 77 | 78 | int cnt = 0; 79 | 80 | for( const String &item : args ) 81 | { 82 | strbuff[cnt] = item; 83 | cnt++; 84 | } 85 | 86 | _serialPtr->setTimeout(timeout); 87 | 88 | while (retry >= 0 ) 89 | { 90 | _serialPtr->write(str.c_str()); 91 | SIMCOM_LOG("[SEND]%s\r\n",str.c_str()); 92 | 93 | int line_cnt = 0; 94 | 95 | while( line_cnt < max_line ) 96 | { 97 | String reviceStr = _serialPtr->readStringUntil('\n'); 98 | if( !reviceStr.isEmpty()) 99 | { 100 | reviceStr.replace("\r",""); reviceStr.replace("\n",""); reviceStr.trim(); 101 | if( reviceStr.length() >= 1 ) 102 | { 103 | SIMCOM_LOG("[REVC]%s\r\n",reviceStr.c_str()); 104 | 105 | if(( reviceStr.indexOf(reviceMark) >= 0 ) && ( revidePtr != nullptr )) 106 | { 107 | int pos = reviceStr.indexOf(reviceMark) + reviceMark.length(); 108 | *revidePtr = reviceStr.substring(pos); 109 | } 110 | else 111 | { 112 | for (int i = 0; i < strlist_size; i++) 113 | { 114 | if( reviceStr.indexOf(strbuff[i]) >= 0 ){ delete[] strbuff; return i; } 115 | } 116 | } 117 | } 118 | } 119 | line_cnt++; 120 | } 121 | retry --; 122 | } 123 | delete[] strbuff; 124 | return -1; 125 | } 126 | 127 | int simcom::waitUntill(String reviceMark,String *revidePtr,int timeout) 128 | { 129 | String reviceStr = _serialPtr->readStringUntil('\n'); 130 | if( !reviceStr.isEmpty()) 131 | { 132 | reviceStr.replace("\r",""); reviceStr.replace("\n",""); reviceStr.trim(); 133 | if( reviceStr.length() >= 1 ) 134 | { 135 | SIMCOM_LOG("[REVC]%s\r\n",reviceStr.c_str()); 136 | 137 | if(( reviceStr.indexOf(reviceMark) >= 0 ) && ( revidePtr != nullptr )) 138 | { 139 | int pos = reviceStr.indexOf(reviceMark) + reviceMark.length(); 140 | *revidePtr = reviceStr.substring(pos); 141 | } 142 | } 143 | } 144 | return 0; 145 | } 146 | 147 | 148 | String simcom::sendCMDAndRevice(String str) 149 | { 150 | return String(); 151 | } 152 | -------------------------------------------------------------------------------- /src/TFTTerminal.cpp: -------------------------------------------------------------------------------- 1 | #include "TFTTerminal.h" 2 | 3 | TFTTerminal::TFTTerminal(TFT_eSprite *dis_buff_ptr) 4 | { 5 | _dis_buff_ptr = dis_buff_ptr; 6 | memset(discharbuff, 0, 55 * 60); 7 | } 8 | 9 | TFTTerminal::~TFTTerminal() 10 | { 11 | 12 | } 13 | 14 | 15 | void TFTTerminal::setcolor( uint16_t color, uint16_t bk_color ) 16 | { 17 | _color = color; 18 | _bkcolor = bk_color; 19 | } 20 | 21 | void TFTTerminal::setGeometry(uint16_t x, uint16_t y, uint16_t w, uint16_t h ) 22 | { 23 | _win_x_pos = x; 24 | _win_y_pos = y; 25 | _win_w = w; 26 | _win_h = h; 27 | 28 | _line_x_limit = _win_w / _font_x_size; 29 | _line_y_limit = _win_h / _font_y_size; 30 | } 31 | 32 | void TFTTerminal::setFontsize(uint8_t size) 33 | { 34 | size = ( size == 0 ) ? 1 : size; 35 | _font_x_size = 6 * size ; 36 | _font_y_size = 8 * size ; 37 | _fontSize = size; 38 | 39 | _line_x_limit = _win_w / _font_x_size; 40 | _line_y_limit = _win_h / _font_y_size; 41 | } 42 | 43 | size_t TFTTerminal::write(uint8_t chardata) 44 | { 45 | 46 | bool flush_page_flag = false; 47 | uint8_t dis_y_pos = 0; 48 | 49 | //if ((chardata == '\r') || (chardata == '\n')) 50 | if ( chardata == '\n' ) 51 | { 52 | xpos = 0; 53 | ypos++; 54 | ypos = ypos % 60; 55 | memset(discharbuff[ypos % 60], 0, 55); 56 | return 1; 57 | } 58 | else if( xpos >= _line_x_limit ) 59 | { 60 | xpos = 0; 61 | ypos++; 62 | ypos = ypos % 60; 63 | memset(discharbuff[ypos % 60], 0, 55); 64 | } 65 | 66 | discharbuff[ypos][xpos] = chardata; 67 | xpos++; 68 | 69 | if ((dispos <= ypos) && ((ypos - dispos) > _line_y_limit)) 70 | { 71 | dispos = ypos - _line_y_limit; 72 | flush_page_flag = true; 73 | } 74 | else if ((dispos <= ypos) && ((ypos - dispos) <= _line_y_limit)) 75 | { 76 | dis_y_pos = ypos - dispos; 77 | flush_page_flag = false; 78 | } 79 | else if ((dispos > ypos) && ((60 - (dispos - ypos)) > _line_y_limit)) 80 | { 81 | dispos = 60 - ( _line_y_limit - ypos ); 82 | flush_page_flag = true; 83 | } 84 | else if ((dispos > ypos) && ((60 - (dispos - ypos)) > _line_y_limit)) 85 | { 86 | dis_y_pos = 60 - ( dispos - ypos ); 87 | flush_page_flag = false; 88 | } 89 | 90 | dispos = dispos % 60; 91 | 92 | _dis_buff_ptr->setTextColor(_color); 93 | _dis_buff_ptr->setTextSize(_fontSize); 94 | 95 | if( flush_page_flag ) 96 | { 97 | _dis_buff_ptr->fillSprite(_bkcolor); 98 | 99 | for (size_t i = 0; i < _line_y_limit; i++) 100 | { 101 | _dis_buff_ptr->drawString((char *)discharbuff[(dispos + i) % 60], 0, i * _font_y_size); 102 | } 103 | } 104 | else 105 | { 106 | _dis_buff_ptr->drawChar(chardata, ( xpos - 1 ) * _font_x_size, dis_y_pos * _font_y_size ); 107 | } 108 | _dis_buff_ptr->pushSprite(_win_x_pos, _win_y_pos); 109 | 110 | return 1; 111 | 112 | } 113 | 114 | size_t TFTTerminal::write(const uint8_t *buffer, size_t size) 115 | { 116 | 117 | while ((size != 0) && (*buffer != '\0')) 118 | { 119 | //if ((*buffer == '\r') || (*buffer == '\n')) 120 | if ( *buffer == '\n' ) 121 | { 122 | xpos = 0; 123 | ypos++; 124 | ypos = ypos % 60; 125 | memset(discharbuff[ypos % 60], 0, 55); 126 | buffer++; 127 | size--; 128 | continue; 129 | } 130 | else if(xpos >= _line_x_limit) 131 | { 132 | xpos = 0; 133 | ypos++; 134 | ypos = ypos % 60; 135 | memset(discharbuff[ypos % 60], 0, 55); 136 | } 137 | discharbuff[ypos][xpos] = *buffer; 138 | xpos++; 139 | buffer++; 140 | size--; 141 | } 142 | 143 | if ((dispos <= ypos) && ((ypos - dispos) > _line_y_limit)) 144 | { 145 | dispos = ypos - _line_y_limit; 146 | } 147 | else if ((dispos > ypos) && ((60 - (dispos - ypos)) > _line_y_limit)) 148 | { 149 | dispos = 60- ( _line_y_limit - ypos ); 150 | } 151 | 152 | dispos = dispos % 60; 153 | 154 | _dis_buff_ptr->setTextColor(_color); 155 | _dis_buff_ptr->setTextSize(_fontSize); 156 | _dis_buff_ptr->fillSprite(_bkcolor); 157 | //_dis_buff_ptr->fillRect(_win_x_pos, _win_y_pos, _win_w, _win_h, _bkcolor); 158 | for (size_t i = 0; i < _line_y_limit; i++) 159 | { 160 | _dis_buff_ptr->drawString((char *)discharbuff[(dispos + i) % 60], 0, i * _font_y_size); 161 | } 162 | _dis_buff_ptr->pushSprite(_win_x_pos, _win_y_pos); 163 | return 1; 164 | } -------------------------------------------------------------------------------- /lib/src/utility/ILI9341_Defines.h: -------------------------------------------------------------------------------- 1 | // Change the width and height if required (defined in portrait mode) 2 | // or use the constructor to over-ride defaults 3 | #define TFT_WIDTH 240 4 | #define TFT_HEIGHT 320 5 | 6 | // Color definitions for backwards compatibility with old sketches 7 | // use colour definitions like TFT_BLACK to make sketches more portable 8 | #define ILI9341_BLACK 0x0000 /* 0, 0, 0 */ 9 | #define ILI9341_NAVY 0x000F /* 0, 0, 128 */ 10 | #define ILI9341_DARKGREEN 0x03E0 /* 0, 128, 0 */ 11 | #define ILI9341_DARKCYAN 0x03EF /* 0, 128, 128 */ 12 | #define ILI9341_MAROON 0x7800 /* 128, 0, 0 */ 13 | #define ILI9341_PURPLE 0x780F /* 128, 0, 128 */ 14 | #define ILI9341_OLIVE 0x7BE0 /* 128, 128, 0 */ 15 | #define ILI9341_LIGHTGREY 0xC618 /* 192, 192, 192 */ 16 | #define ILI9341_DARKGREY 0x7BEF /* 128, 128, 128 */ 17 | #define ILI9341_BLUE 0x001F /* 0, 0, 255 */ 18 | #define ILI9341_GREEN 0x07E0 /* 0, 255, 0 */ 19 | #define ILI9341_CYAN 0x07FF /* 0, 255, 255 */ 20 | #define ILI9341_RED 0xF800 /* 255, 0, 0 */ 21 | #define ILI9341_MAGENTA 0xF81F /* 255, 0, 255 */ 22 | #define ILI9341_YELLOW 0xFFE0 /* 255, 255, 0 */ 23 | #define ILI9341_WHITE 0xFFFF /* 255, 255, 255 */ 24 | #define ILI9341_ORANGE 0xFD20 /* 255, 165, 0 */ 25 | #define ILI9341_GREENYELLOW 0xAFE5 /* 173, 255, 47 */ 26 | #define ILI9341_PINK 0xF81F 27 | 28 | #define BLACK 0x0000 /* 0, 0, 0 */ 29 | #define NAVY 0x000F /* 0, 0, 128 */ 30 | #define DARKGREEN 0x03E0 /* 0, 128, 0 */ 31 | #define DARKCYAN 0x03EF /* 0, 128, 128 */ 32 | #define MAROON 0x7800 /* 128, 0, 0 */ 33 | #define PURPLE 0x780F /* 128, 0, 128 */ 34 | #define OLIVE 0x7BE0 /* 128, 128, 0 */ 35 | #define LIGHTGREY 0xC618 /* 192, 192, 192 */ 36 | #define DARKGREY 0x7BEF /* 128, 128, 128 */ 37 | #define BLUE 0x001F /* 0, 0, 255 */ 38 | #define GREEN 0x07E0 /* 0, 255, 0 */ 39 | #define CYAN 0x07FF /* 0, 255, 255 */ 40 | #define RED 0xF800 /* 255, 0, 0 */ 41 | #define MAGENTA 0xF81F /* 255, 0, 255 */ 42 | #define YELLOW 0xFFE0 /* 255, 255, 0 */ 43 | #define WHITE 0xFFFF /* 255, 255, 255 */ 44 | #define ORANGE 0xFD20 /* 255, 165, 0 */ 45 | #define GREENYELLOW 0xAFE5 /* 173, 255, 47 */ 46 | #define PINK 0xF81F 47 | 48 | 49 | // Delay between some initialisation commands 50 | #define TFT_INIT_DELAY 0x80 // Not used unless commandlist invoked 51 | 52 | 53 | // Generic commands used by TFT_eSPI.cpp 54 | #define TFT_NOP 0x00 55 | #define TFT_SWRST 0x01 56 | 57 | #define TFT_CASET 0x2A 58 | #define TFT_PASET 0x2B 59 | #define TFT_RAMWR 0x2C 60 | 61 | #define TFT_RAMRD 0x2E 62 | #define TFT_IDXRD 0xDD // ILI9341 only, indexed control register read 63 | 64 | #define TFT_MADCTL 0x36 65 | #define TFT_MAD_MY 0x80 66 | #define TFT_MAD_MX 0x40 67 | #define TFT_MAD_MV 0x20 68 | #define TFT_MAD_ML 0x10 69 | #define TFT_MAD_BGR 0x08 70 | #define TFT_MAD_MH 0x04 71 | #define TFT_MAD_RGB 0x00 72 | 73 | #define TFT_INVOFF 0x20 74 | #define TFT_INVON 0x21 75 | 76 | 77 | // All ILI9341 specific commands some are used by init() 78 | #define ILI9341_NOP 0x00 79 | #define ILI9341_SWRESET 0x01 80 | #define ILI9341_RDDID 0x04 81 | #define ILI9341_RDDST 0x09 82 | 83 | #define ILI9341_SLPIN 0x10 84 | #define ILI9341_SLPOUT 0x11 85 | #define ILI9341_PTLON 0x12 86 | #define ILI9341_NORON 0x13 87 | 88 | #define ILI9341_RDMODE 0x0A 89 | #define ILI9341_RDMADCTL 0x0B 90 | #define ILI9341_RDPIXFMT 0x0C 91 | #define ILI9341_RDIMGFMT 0x0A 92 | #define ILI9341_RDSELFDIAG 0x0F 93 | 94 | #define ILI9341_INVOFF 0x20 95 | #define ILI9341_INVON 0x21 96 | #define ILI9341_GAMMASET 0x26 97 | #define ILI9341_DISPOFF 0x28 98 | #define ILI9341_DISPON 0x29 99 | 100 | #define ILI9341_CASET 0x2A 101 | #define ILI9341_PASET 0x2B 102 | #define ILI9341_RAMWR 0x2C 103 | #define ILI9341_RAMRD 0x2E 104 | 105 | #define ILI9341_PTLAR 0x30 106 | #define ILI9341_VSCRDEF 0x33 107 | #define ILI9341_MADCTL 0x36 108 | #define ILI9341_VSCRSADD 0x37 109 | #define ILI9341_PIXFMT 0x3A 110 | 111 | #define ILI9341_WRDISBV 0x51 112 | #define ILI9341_RDDISBV 0x52 113 | #define ILI9341_WRCTRLD 0x53 114 | 115 | #define ILI9341_FRMCTR1 0xB1 116 | #define ILI9341_FRMCTR2 0xB2 117 | #define ILI9341_FRMCTR3 0xB3 118 | #define ILI9341_INVCTR 0xB4 119 | #define ILI9341_DFUNCTR 0xB6 120 | 121 | #define ILI9341_PWCTR1 0xC0 122 | #define ILI9341_PWCTR2 0xC1 123 | #define ILI9341_PWCTR3 0xC2 124 | #define ILI9341_PWCTR4 0xC3 125 | #define ILI9341_PWCTR5 0xC4 126 | #define ILI9341_VMCTR1 0xC5 127 | #define ILI9341_VMCTR2 0xC7 128 | 129 | #define ILI9341_RDID4 0xD3 130 | #define ILI9341_RDINDEX 0xD9 131 | #define ILI9341_RDID1 0xDA 132 | #define ILI9341_RDID2 0xDB 133 | #define ILI9341_RDID3 0xDC 134 | #define ILI9341_RDIDX 0xDD // TBC 135 | 136 | #define ILI9341_GMCTRP1 0xE0 137 | #define ILI9341_GMCTRN1 0xE1 138 | 139 | #define ILI9341_MADCTL_MY 0x80 140 | #define ILI9341_MADCTL_MX 0x40 141 | #define ILI9341_MADCTL_MV 0x20 142 | #define ILI9341_MADCTL_ML 0x10 143 | #define ILI9341_MADCTL_RGB 0x00 144 | #define ILI9341_MADCTL_BGR 0x08 145 | #define ILI9341_MADCTL_MH 0x04 146 | -------------------------------------------------------------------------------- /lib/src/utility/CommUtil.cpp: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------------------* 2 | * M5Stack I2C Common Library v1.0 * 3 | * * 4 | * This work is licensed under the GNU Lesser General Public * 5 | * License v2.1 * 6 | * https://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html * 7 | *----------------------------------------------------------------------*/ 8 | #include "CommUtil.h" 9 | #include "../M5Stack.h" 10 | 11 | extern M5Stack M5; 12 | 13 | //debug for message of I2C ( bypass message to serial) 14 | //#define I2C_DEBUG_TO_SERIAL 15 | 16 | CommUtil::CommUtil() { 17 | } 18 | 19 | // Wire.h read and write protocols 20 | bool CommUtil::writeCommand(uint8_t address, uint8_t subAddress) { 21 | bool function_result = false; 22 | Wire.beginTransmission(address); // Initialize the Tx buffer 23 | Wire.write(subAddress); // Put slave register address in Tx buffer 24 | function_result = (Wire.endTransmission() == 0); // Send the Tx buffer 25 | 26 | #ifdef I2C_DEBUG_TO_SERIAL 27 | Serial.printf("writeCommand:send to 0x%02x [0x%02x] result:%s\n", address, subAddress, function_result ? "OK" : "NG"); 28 | #endif 29 | 30 | return (function_result); 31 | } 32 | 33 | // Wire.h read and write protocols 34 | bool CommUtil::writeByte(uint8_t address, uint8_t subAddress, uint8_t data) { 35 | bool function_result = false; 36 | Wire.beginTransmission(address); // Initialize the Tx buffer 37 | Wire.write(subAddress); // Put slave register address in Tx buffer 38 | Wire.write(data); // Put data in Tx buffer 39 | function_result = (Wire.endTransmission() == 0); // Send the Tx buffer 40 | 41 | #ifdef I2C_DEBUG_TO_SERIAL 42 | Serial.printf("writeByte:send to 0x%02x [0x%2x] data=0x%02x result:%s\n", address, subAddress, data, function_result ? "OK" : "NG"); 43 | #endif 44 | 45 | return (function_result); 46 | } 47 | 48 | // Wire.h read and write protocols 49 | bool CommUtil::writeBytes(uint8_t address, uint8_t subAddress, uint8_t *data, uint8_t length) { 50 | bool function_result = false; 51 | 52 | #ifdef I2C_DEBUG_TO_SERIAL 53 | Serial.printf("writeBytes:send to 0x%02x [0x%02x] data=",address,subAddress); 54 | #endif 55 | 56 | Wire.beginTransmission(address); // Initialize the Tx buffer 57 | Wire.write(subAddress); // Put slave register address in Tx buffer 58 | for(int i = 0; i < length; i++) { 59 | Wire.write(*(data+i)); // Put data in Tx buffer 60 | #ifdef I2C_DEBUG_TO_SERIAL 61 | Serial.printf("%02x ", *(data+i)); 62 | #endif 63 | } 64 | function_result = (Wire.endTransmission() == 0); // Send the Tx buffer 65 | 66 | #ifdef I2C_DEBUG_TO_SERIAL 67 | Serial.printf("result:%s\n", function_result ? "OK" : "NG"); 68 | #endif 69 | 70 | return function_result; // Send the Tx buffer 71 | } 72 | 73 | bool CommUtil::readByte(uint8_t address, uint8_t *result) { 74 | #ifdef I2C_DEBUG_TO_SERIAL 75 | Serial.printf("readByte :read from 0x%02x requestByte=1 receive=", address); 76 | #endif 77 | 78 | if ( Wire.requestFrom(address, (uint8_t)1)) { 79 | *result = Wire.read(); // Fill Rx buffer with result 80 | #ifdef I2C_DEBUG_TO_SERIAL 81 | Serial.printf("%02x\n", result); 82 | #endif 83 | return true; 84 | } 85 | #ifdef I2C_DEBUG_TO_SERIAL 86 | Serial.printf("none\n"); 87 | #endif 88 | return false; 89 | } 90 | 91 | bool CommUtil::readByte(uint8_t address, uint8_t subAddress,uint8_t *result) { 92 | #ifdef I2C_DEBUG_TO_SERIAL 93 | Serial.printf("readByte :read from 0x%02x [0x%02x] requestByte=1 receive=", address, subAddress); 94 | #endif 95 | 96 | Wire.beginTransmission(address); // Initialize the Tx buffer 97 | Wire.write(subAddress); // Put slave register address in Tx buffer 98 | if (Wire.endTransmission(false) == 0 && Wire.requestFrom(address, (uint8_t)1)) { 99 | *result = Wire.read(); // Fill Rx buffer with result 100 | #ifdef I2C_DEBUG_TO_SERIAL 101 | Serial.printf("%02x\n",*result); 102 | #endif 103 | return true; 104 | } 105 | #ifdef I2C_DEBUG_TO_SERIAL 106 | Serial.printf("none\n"); 107 | #endif 108 | return false; 109 | } 110 | 111 | bool CommUtil::readBytes(uint8_t address, uint8_t subAddress, uint8_t count,uint8_t * dest) { 112 | #ifdef I2C_DEBUG_TO_SERIAL 113 | Serial.printf("readBytes:read from 0x%02x [0x%02x] requestByte=%d receive=", address, subAddress, count); 114 | #endif 115 | 116 | Wire.beginTransmission(address); // Initialize the Tx buffer 117 | Wire.write(subAddress); // Put slave register address in Tx buffer 118 | uint8_t i = 0; 119 | if (Wire.endTransmission(false) == 0 && Wire.requestFrom(address, (uint8_t)count)) { 120 | while (Wire.available()) { 121 | dest[i++] = Wire.read();// Put read results in the Rx buffer 122 | #ifdef I2C_DEBUG_TO_SERIAL 123 | Serial.printf("%02x ", dest[i-1]); 124 | #endif 125 | } 126 | #ifdef I2C_DEBUG_TO_SERIAL 127 | Serial.printf(" (len:%d)\n", i); 128 | #endif 129 | return true; 130 | } 131 | #ifdef I2C_DEBUG_TO_SERIAL 132 | Serial.printf("none\n"); 133 | #endif 134 | return false; 135 | } 136 | 137 | bool CommUtil::readBytes(uint8_t address, uint8_t count,uint8_t * dest) { 138 | uint8_t i = 0; 139 | if (Wire.requestFrom(address, (uint8_t)count)) { 140 | while (Wire.available()) { 141 | // Put read results in the Rx buffer 142 | dest[i++] = Wire.read(); 143 | } 144 | return true; 145 | } 146 | return false; 147 | } 148 | 149 | void CommUtil::scanID(bool *result) { 150 | for(int i=0x00;i<=0x7f;i++) { 151 | *(result+i)=writeCommand(i,0x00); 152 | } 153 | } 154 | -------------------------------------------------------------------------------- /lib/src/utility/M5Timer.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * M5Timer.cpp 3 | * 4 | * M5Timer - A timer library for Arduino. 5 | * Author: mromani@ottotecnica.com 6 | * Copyright (c) 2010 OTTOTECNICA Italy 7 | * 8 | * This library is free software; you can redistribute it 9 | * and/or modify it under the terms of the GNU Lesser 10 | * General Public License as published by the Free Software 11 | * Foundation; either version 2.1 of the License, or (at 12 | * your option) any later version. 13 | * 14 | * This library is distributed in the hope that it will 15 | * be useful, but WITHOUT ANY WARRANTY; without even the 16 | * implied warranty of MERCHANTABILITY or FITNESS FOR A 17 | * PARTICULAR PURPOSE. See the GNU Lesser General Public 18 | * License for more details. 19 | * 20 | * You should have received a copy of the GNU Lesser 21 | * General Public License along with this library; if not, 22 | * write to the Free Software Foundation, Inc., 23 | * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 24 | */ 25 | 26 | #include "M5Timer.h" 27 | 28 | // Select time function: 29 | //static inline unsigned long elapsed() { return micros(); } 30 | static inline unsigned long elapsed() { return millis(); } 31 | 32 | M5Timer::M5Timer() { 33 | unsigned long current_millis = elapsed(); 34 | 35 | for (int i = 0; i < MAX_TIMERS; i++) { 36 | enabled[i] = false; 37 | callbacks[i] = 0; // if the callback pointer is zero, the slot is free, i.e. doesn't "contain" any timer 38 | prev_millis[i] = current_millis; 39 | numRuns[i] = 0; 40 | } 41 | numTimers = 0; 42 | } 43 | 44 | void M5Timer::run() { 45 | int i; 46 | unsigned long current_millis; 47 | 48 | // get current time 49 | current_millis = elapsed(); 50 | 51 | for (i = 0; i < MAX_TIMERS; i++) { 52 | toBeCalled[i] = DEFCALL_DONTRUN; 53 | 54 | // no callback == no timer, i.e. jump over empty slots 55 | if (callbacks[i] != 0) { 56 | 57 | // is it time to process this timer ? 58 | // see http://arduino.cc/forum/index.php/topic,124048.msg932592.html#msg932592 59 | 60 | if (current_millis - prev_millis[i] >= delays[i]) { 61 | // update time 62 | //prev_millis[i] = current_millis; 63 | prev_millis[i] += delays[i]; 64 | 65 | // check if the timer callback has to be executed 66 | if (enabled[i] == true) { 67 | // "run forever" timers must always be executed 68 | if (maxNumRuns[i] == RUN_FOREVER) { 69 | toBeCalled[i] = DEFCALL_RUNONLY; 70 | }else if (numRuns[i] < maxNumRuns[i]) { 71 | // other timers get executed the specified number of times 72 | toBeCalled[i] = DEFCALL_RUNONLY; 73 | numRuns[i]++; 74 | // after the last run, delete the timer 75 | if (numRuns[i] >= maxNumRuns[i]) { 76 | toBeCalled[i] = DEFCALL_RUNANDDEL; 77 | } 78 | } 79 | } 80 | } 81 | } 82 | } 83 | for (i = 0; i < MAX_TIMERS; i++) { 84 | switch (toBeCalled[i]) { 85 | case DEFCALL_DONTRUN: 86 | break; 87 | 88 | case DEFCALL_RUNONLY: 89 | callbacks[i](); 90 | break; 91 | 92 | case DEFCALL_RUNANDDEL: 93 | callbacks[i](); 94 | deleteTimer(i); 95 | break; 96 | } 97 | } 98 | } 99 | 100 | // find the first available slot 101 | // return -1 if none found 102 | int M5Timer::findFirstFreeSlot() { 103 | int i; 104 | 105 | // all slots are used 106 | if (numTimers >= MAX_TIMERS) { 107 | return -1; 108 | } 109 | 110 | // return the first slot with no callback (i.e. free) 111 | for (i = 0; i < MAX_TIMERS; i++) { 112 | if (callbacks[i] == 0) { 113 | return i; 114 | } 115 | } 116 | // no free slots found 117 | return -1; 118 | } 119 | 120 | int M5Timer::setTimer(long d, timer_callback f, int n) { 121 | int freeTimer; 122 | 123 | freeTimer = findFirstFreeSlot(); 124 | if (freeTimer < 0) { 125 | return -1; 126 | } 127 | 128 | if (f == NULL) { 129 | return -1; 130 | } 131 | 132 | delays[freeTimer] = d; 133 | callbacks[freeTimer] = f; 134 | maxNumRuns[freeTimer] = n; 135 | enabled[freeTimer] = true; 136 | prev_millis[freeTimer] = elapsed(); 137 | 138 | numTimers++; 139 | 140 | return freeTimer; 141 | } 142 | 143 | int M5Timer::setInterval(long d, timer_callback f) { 144 | return setTimer(d, f, RUN_FOREVER); 145 | } 146 | 147 | int M5Timer::setTimeout(long d, timer_callback f) { 148 | return setTimer(d, f, RUN_ONCE); 149 | } 150 | 151 | void M5Timer::deleteTimer(int timerId) { 152 | if (timerId >= MAX_TIMERS) { 153 | return; 154 | } 155 | 156 | // nothing to delete if no timers are in use 157 | if (numTimers == 0) { 158 | return; 159 | } 160 | 161 | // don't decrease the number of timers if the 162 | // specified slot is already empty 163 | if (callbacks[timerId] != NULL) { 164 | callbacks[timerId] = 0; 165 | enabled[timerId] = false; 166 | toBeCalled[timerId] = DEFCALL_DONTRUN; 167 | delays[timerId] = 0; 168 | numRuns[timerId] = 0; 169 | 170 | // update number of timers 171 | numTimers--; 172 | } 173 | } 174 | 175 | // function contributed by code@rowansimms.com 176 | void M5Timer::restartTimer(int numTimer) { 177 | if (numTimer >= MAX_TIMERS) { 178 | return; 179 | } 180 | 181 | prev_millis[numTimer] = elapsed(); 182 | } 183 | 184 | boolean M5Timer::isEnabled(int numTimer) { 185 | if (numTimer >= MAX_TIMERS) { 186 | return false; 187 | } 188 | 189 | return enabled[numTimer]; 190 | } 191 | 192 | void M5Timer::enable(int numTimer) { 193 | if (numTimer >= MAX_TIMERS) { 194 | return; 195 | } 196 | 197 | enabled[numTimer] = true; 198 | } 199 | 200 | void M5Timer::disable(int numTimer) { 201 | if (numTimer >= MAX_TIMERS) { 202 | return; 203 | } 204 | 205 | enabled[numTimer] = false; 206 | } 207 | 208 | void M5Timer::toggle(int numTimer) { 209 | if (numTimer >= MAX_TIMERS) { 210 | return; 211 | } 212 | 213 | enabled[numTimer] = !enabled[numTimer]; 214 | } 215 | 216 | int M5Timer::getNumTimers() { 217 | return numTimers; 218 | } 219 | -------------------------------------------------------------------------------- /lib/src/utility/Button.cpp: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------------------* 2 | * Arduino Button Library v1.0 * 3 | * Jack Christensen May 2011, published Mar 2012 * 4 | * * 5 | * Library for reading momentary contact switches like tactile button * 6 | * switches. Intended for use in state machine constructs. * 7 | * Use the read() function to read all buttons in the main loop, * 8 | * which should execute as fast as possible. * 9 | * * 10 | * This work is licensed under the Creative Commons Attribution- * 11 | * ShareAlike 3.0 Unported License. To view a copy of this license, * 12 | * visit http://creativecommons.org/licenses/by-sa/3.0/ or send a * 13 | * letter to Creative Commons, 171 Second Street, Suite 300, * 14 | * San Francisco, California, 94105, USA. * 15 | *----------------------------------------------------------------------*/ 16 | 17 | #include "Button.h" 18 | 19 | /*----------------------------------------------------------------------* 20 | * Button(pin, puEnable, invert, dbTime) instantiates a button object. * 21 | * pin Is the Arduino pin the button is connected to. * 22 | * puEnable Enables the AVR internal pullup resistor if != 0 (can also * 23 | * use true or false). * 24 | * invert If invert == 0, interprets a high state as pressed, low as * 25 | * released. If invert != 0, interprets a high state as * 26 | * released, low as pressed (can also use true or false). * 27 | * dbTime Is the debounce time in milliseconds. * 28 | * * 29 | * (Note that invert cannot be implied from puEnable since an external * 30 | * pullup could be used.) * 31 | *----------------------------------------------------------------------*/ 32 | Button::Button(uint8_t pin, uint8_t invert, uint32_t dbTime) { 33 | _pin = pin; 34 | _invert = invert; 35 | _dbTime = dbTime; 36 | pinMode(_pin, INPUT_PULLUP); 37 | _state = digitalRead(_pin); 38 | if (_invert != 0) _state = !_state; 39 | _time = millis(); 40 | _lastState = _state; 41 | _changed = 0; 42 | _hold_time = -1; 43 | _lastTime = _time; 44 | _lastChange = _time; 45 | _pressTime = _time; 46 | } 47 | 48 | /*----------------------------------------------------------------------* 49 | * read() returns the state of the button, 1==pressed, 0==released, * 50 | * does debouncing, captures and maintains times, previous states, etc. * 51 | *----------------------------------------------------------------------*/ 52 | uint8_t Button::read(void) { 53 | static uint32_t ms; 54 | static uint8_t pinVal; 55 | 56 | ms = millis(); 57 | pinVal = digitalRead(_pin); 58 | if (_invert != 0) pinVal = !pinVal; 59 | if (ms - _lastChange < _dbTime) { 60 | _lastTime = _time; 61 | _time = ms; 62 | _changed = 0; 63 | return _state; 64 | } 65 | else { 66 | _lastTime = _time; 67 | _time = ms; 68 | _lastState = _state; 69 | _state = pinVal; 70 | if (_state != _lastState) { 71 | _lastChange = ms; 72 | _changed = 1; 73 | if (_state) { _pressTime = _time; } 74 | } 75 | else { 76 | _changed = 0; 77 | } 78 | return _state; 79 | } 80 | } 81 | 82 | /*----------------------------------------------------------------------* 83 | * isPressed() and isReleased() check the button state when it was last * 84 | * read, and return false (0) or true (!=0) accordingly. * 85 | * These functions do not cause the button to be read. * 86 | *----------------------------------------------------------------------*/ 87 | uint8_t Button::isPressed(void) { 88 | return _state == 0 ? 0 : 1; 89 | } 90 | 91 | uint8_t Button::isReleased(void) { 92 | return _state == 0 ? 1 : 0; 93 | } 94 | 95 | /*----------------------------------------------------------------------* 96 | * wasPressed() and wasReleased() check the button state to see if it * 97 | * changed between the last two reads and return false (0) or * 98 | * true (!=0) accordingly. * 99 | * These functions do not cause the button to be read. * 100 | *----------------------------------------------------------------------*/ 101 | uint8_t Button::wasPressed(void) { 102 | return _state && _changed; 103 | } 104 | 105 | uint8_t Button::wasReleased(void) { 106 | return !_state && _changed && millis() - _pressTime < _hold_time; 107 | } 108 | 109 | uint8_t Button::wasReleasefor(uint32_t ms) { 110 | _hold_time = ms; 111 | return !_state && _changed && millis() - _pressTime >= ms; 112 | } 113 | /*----------------------------------------------------------------------* 114 | * pressedFor(ms) and releasedFor(ms) check to see if the button is * 115 | * pressed (or released), and has been in that state for the specified * 116 | * time in milliseconds. Returns false (0) or true (1) accordingly. * 117 | * These functions do not cause the button to be read. * 118 | *----------------------------------------------------------------------*/ 119 | uint8_t Button::pressedFor(uint32_t ms) { 120 | return (_state == 1 && _time - _lastChange >= ms) ? 1 : 0; 121 | } 122 | 123 | uint8_t Button::releasedFor(uint32_t ms) { 124 | return (_state == 0 && _time - _lastChange >= ms) ? 1 : 0; 125 | } 126 | /*----------------------------------------------------------------------* 127 | * lastChange() returns the time the button last changed state, * 128 | * in milliseconds. * 129 | *----------------------------------------------------------------------*/ 130 | uint32_t Button::lastChange(void) { 131 | return _lastChange; 132 | } 133 | -------------------------------------------------------------------------------- /lib/src/utility/MPU6886.cpp: -------------------------------------------------------------------------------- 1 | #include "MPU6886.h" 2 | #include 3 | #include 4 | #include "../M5Stack.h" 5 | #include "MahonyAHRS.h" 6 | 7 | MPU6886::MPU6886(){ 8 | 9 | } 10 | 11 | void MPU6886::I2C_Read_NBytes(uint8_t driver_Addr, uint8_t start_Addr, uint8_t number_Bytes, uint8_t *read_Buffer){ 12 | M5.I2C.readBytes(driver_Addr, start_Addr, number_Bytes, read_Buffer); 13 | } 14 | 15 | void MPU6886::I2C_Write_NBytes(uint8_t driver_Addr, uint8_t start_Addr, uint8_t number_Bytes, uint8_t *write_Buffer) { 16 | M5.I2C.writeBytes(driver_Addr, start_Addr, write_Buffer, number_Bytes); 17 | } 18 | 19 | int MPU6886::Init(void) { 20 | unsigned char tempdata[1]; 21 | unsigned char regdata; 22 | 23 | Gyscale = GFS_2000DPS; 24 | Acscale = AFS_8G; 25 | 26 | Wire1.begin(21,22); 27 | 28 | I2C_Read_NBytes(MPU6886_ADDRESS, MPU6886_WHOAMI, 1, tempdata); 29 | imuId = tempdata[0]; 30 | delay(1); 31 | 32 | regdata = 0x00; 33 | I2C_Write_NBytes(MPU6886_ADDRESS, MPU6886_PWR_MGMT_1, 1, ®data); 34 | delay(10); 35 | 36 | regdata = (0x01<<7); 37 | I2C_Write_NBytes(MPU6886_ADDRESS, MPU6886_PWR_MGMT_1, 1, ®data); 38 | delay(10); 39 | 40 | regdata = (0x01<<0); 41 | I2C_Write_NBytes(MPU6886_ADDRESS, MPU6886_PWR_MGMT_1, 1, ®data); 42 | delay(10); 43 | 44 | regdata = 0x10; 45 | I2C_Write_NBytes(MPU6886_ADDRESS, MPU6886_ACCEL_CONFIG, 1, ®data); 46 | delay(1); 47 | 48 | regdata = 0x18; 49 | I2C_Write_NBytes(MPU6886_ADDRESS, MPU6886_GYRO_CONFIG, 1, ®data); 50 | delay(1); 51 | 52 | regdata = 0x01; 53 | I2C_Write_NBytes(MPU6886_ADDRESS, MPU6886_CONFIG, 1, ®data); 54 | delay(1); 55 | 56 | regdata = 0x05; 57 | I2C_Write_NBytes(MPU6886_ADDRESS, MPU6886_SMPLRT_DIV, 1,®data); 58 | delay(1); 59 | 60 | regdata = 0x00; 61 | I2C_Write_NBytes(MPU6886_ADDRESS, MPU6886_INT_ENABLE, 1, ®data); 62 | delay(1); 63 | 64 | regdata = 0x00; 65 | I2C_Write_NBytes(MPU6886_ADDRESS, MPU6886_ACCEL_CONFIG2, 1, ®data); 66 | delay(1); 67 | 68 | regdata = 0x00; 69 | I2C_Write_NBytes(MPU6886_ADDRESS, MPU6886_USER_CTRL, 1, ®data); 70 | delay(1); 71 | 72 | regdata = 0x00; 73 | I2C_Write_NBytes(MPU6886_ADDRESS, MPU6886_FIFO_EN, 1, ®data); 74 | delay(1); 75 | 76 | regdata = 0x22; 77 | I2C_Write_NBytes(MPU6886_ADDRESS, MPU6886_INT_PIN_CFG, 1, ®data); 78 | delay(1); 79 | 80 | regdata = 0x01; 81 | I2C_Write_NBytes(MPU6886_ADDRESS, MPU6886_INT_ENABLE, 1, ®data); 82 | 83 | delay(10); 84 | 85 | setGyroFsr(Gyscale); 86 | setAccelFsr(Acscale); 87 | return 0; 88 | } 89 | 90 | void MPU6886::getAccelAdc(int16_t* ax, int16_t* ay, int16_t* az) { 91 | uint8_t buf[6]; 92 | I2C_Read_NBytes(MPU6886_ADDRESS, MPU6886_ACCEL_XOUT_H, 6, buf); 93 | 94 | *ax=((int16_t)buf[0]<<8)|buf[1]; 95 | *ay=((int16_t)buf[2]<<8)|buf[3]; 96 | *az=((int16_t)buf[4]<<8)|buf[5]; 97 | } 98 | 99 | void MPU6886::getGyroAdc(int16_t* gx, int16_t* gy, int16_t* gz) { 100 | uint8_t buf[6]; 101 | I2C_Read_NBytes(MPU6886_ADDRESS,MPU6886_GYRO_XOUT_H, 6, buf); 102 | 103 | *gx=((uint16_t)buf[0]<<8)|buf[1]; 104 | *gy=((uint16_t)buf[2]<<8)|buf[3]; 105 | *gz=((uint16_t)buf[4]<<8)|buf[5]; 106 | } 107 | 108 | void MPU6886::getTempAdc(int16_t *t) { 109 | uint8_t buf[2]; 110 | I2C_Read_NBytes(MPU6886_ADDRESS,MPU6886_TEMP_OUT_H,2,buf); 111 | 112 | *t=((uint16_t)buf[0]<<8)|buf[1]; 113 | } 114 | 115 | //!俯仰,航向,横滚:pitch,yaw,roll,指三维空间中飞行器的旋转状态。 116 | void MPU6886::getAhrsData(float *pitch, float *roll, float *yaw) { 117 | 118 | float accX = 0; 119 | float accY = 0; 120 | float accZ = 0; 121 | 122 | float gyroX = 0; 123 | float gyroY = 0; 124 | float gyroZ = 0; 125 | 126 | 127 | getGyroData(&gyroX, &gyroY, &gyroZ); 128 | getAccelData(&accX, &accY, &accZ); 129 | 130 | MahonyAHRSupdateIMU(gyroX * DEG_TO_RAD, gyroY * DEG_TO_RAD, gyroZ * DEG_TO_RAD, accX, accY, accZ, pitch, roll, yaw); 131 | } 132 | 133 | // Possible gyro scales (and their register bit settings) 134 | void MPU6886::updateGres() { 135 | switch (Gyscale) { 136 | case GFS_250DPS: 137 | gRes = 250.0/32768.0; 138 | break; 139 | case GFS_500DPS: 140 | gRes = 500.0/32768.0; 141 | break; 142 | case GFS_1000DPS: 143 | gRes = 1000.0/32768.0; 144 | break; 145 | case GFS_2000DPS: 146 | gRes = 2000.0/32768.0; 147 | break; 148 | } 149 | 150 | } 151 | 152 | // Possible accelerometer scales (and their register bit settings) are: 153 | // 2 Gs (00), 4 Gs (01), 8 Gs (10), and 16 Gs (11). 154 | // Here's a bit of an algorith to calculate DPS/(ADC tick) based on that 2-bit value: 155 | void MPU6886::updateAres() { 156 | switch (Acscale) { 157 | case AFS_2G: 158 | aRes = 2.0/32768.0; 159 | break; 160 | case AFS_4G: 161 | aRes = 4.0/32768.0; 162 | break; 163 | case AFS_8G: 164 | aRes = 8.0/32768.0; 165 | break; 166 | case AFS_16G: 167 | aRes = 16.0/32768.0; 168 | break; 169 | } 170 | } 171 | 172 | void MPU6886::setGyroFsr(Gscale scale) { 173 | unsigned char regdata; 174 | regdata = (scale<<3); 175 | I2C_Write_NBytes(MPU6886_ADDRESS, MPU6886_GYRO_CONFIG, 1, ®data); 176 | delay(10); 177 | Gyscale = scale; 178 | updateGres(); 179 | } 180 | 181 | void MPU6886::setAccelFsr(Ascale scale) { 182 | unsigned char regdata; 183 | regdata = (scale<<3); 184 | I2C_Write_NBytes(MPU6886_ADDRESS, MPU6886_ACCEL_CONFIG, 1, ®data); 185 | delay(10); 186 | Acscale = scale; 187 | updateAres(); 188 | } 189 | 190 | void MPU6886::getAccelData(float* ax, float* ay, float* az) { 191 | int16_t accX = 0; 192 | int16_t accY = 0; 193 | int16_t accZ = 0; 194 | getAccelAdc(&accX,&accY,&accZ); 195 | 196 | *ax = (float)accX * aRes; 197 | *ay = (float)accY * aRes; 198 | *az = (float)accZ * aRes; 199 | } 200 | 201 | void MPU6886::getGyroData(float* gx, float* gy, float* gz) { 202 | int16_t gyroX = 0; 203 | int16_t gyroY = 0; 204 | int16_t gyroZ = 0; 205 | getGyroAdc(&gyroX,&gyroY,&gyroZ); 206 | 207 | *gx = (float)gyroX * gRes; 208 | *gy = (float)gyroY * gRes; 209 | *gz = (float)gyroZ * gRes; 210 | } 211 | 212 | void MPU6886::getTempData(float *t) { 213 | int16_t temp = 0; 214 | getTempAdc(&temp); 215 | 216 | *t = (float)temp / 326.8 + 25.0; 217 | } 218 | -------------------------------------------------------------------------------- /lib/src/M5Stack.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) M5Stack. All rights reserved. 2 | 3 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 4 | /** 5 | * \par Copyright (C), 2016-2017, M5Stack 6 | * \class M5Stack 7 | * \brief M5Stack library. 8 | * @file M5Stack.h 9 | * @author M5Stack 10 | * @version V0.2.4 11 | * @date 2018/10/29 12 | * @brief Header for M5Stack.cpp module 13 | * 14 | * \par Description 15 | * This file is a drive for M5Stack core. 16 | * 17 | * \par Method List: 18 | * 19 | * System: 20 | M5.begin(); 21 | M5.update(); 22 | 23 | Power: 24 | M5.Power.setPowerBoostKeepOn() 25 | M5.Power.setCharge(uint8_t mode); 26 | M5.Power.setPowerBoostKeepOn(bool en); 27 | M5.Power.isChargeFull(); 28 | M5.Power.setWakeupButton(uint8_t button); 29 | M5.Power.powerOFF(); 30 | 31 | bool setPowerBoostOnOff(bool en); 32 | bool setPowerBoostSet(bool en); 33 | bool setPowerVin(bool en); 34 | bool setPowerWLEDSet(bool en); 35 | 36 | LCD: 37 | M5.lcd.setBrightness(uint8_t brightness); 38 | M5.Lcd.drawPixel(int16_t x, int16_t y, uint16_t color); 39 | M5.Lcd.drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t color); 40 | M5.Lcd.fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color); 41 | M5.Lcd.fillScreen(uint16_t color); 42 | M5.Lcd.drawCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color); 43 | M5.Lcd.drawCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t cornername,uint16_t color); 44 | M5.Lcd.fillCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color); 45 | M5.Lcd.fillCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t cornername,int16_t delta, uint16_t color); 46 | M5.Lcd.drawTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color); 47 | M5.Lcd.fillTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color); 48 | M5.Lcd.drawRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h, int16_t radius, uint16_t color); 49 | M5.Lcd.fillRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h, int16_t radius, uint16_t color); 50 | M5.Lcd.drawBitmap(int16_t x, int16_t y, const uint8_t bitmap[], int16_t w, int16_t h, uint16_t color); 51 | M5.Lcd.drawRGBBitmap(int16_t x, int16_t y, const uint16_t bitmap[], int16_t w, int16_t h), 52 | M5.Lcd.drawChar(uint16_t x, uint16_t y, char c, uint16_t color, uint16_t bg, uint8_t size); 53 | M5.Lcd.setCursor(uint16_t x0, uint16_t y0); 54 | M5.Lcd.setTextColor(uint16_t color); 55 | M5.Lcd.setTextColor(uint16_t color, uint16_t backgroundcolor); 56 | M5.Lcd.setTextSize(uint8_t size); 57 | M5.Lcd.setTextWrap(boolean w); 58 | M5.Lcd.printf(); 59 | M5.Lcd.print(); 60 | M5.Lcd.println(); 61 | M5.Lcd.drawCentreString(const char *string, int dX, int poY, int font); 62 | M5.Lcd.drawRightString(const char *string, int dX, int poY, int font); 63 | M5.Lcd.drawJpg(const uint8_t *jpg_data, size_t jpg_len, uint16_t x, uint16_t y); 64 | M5.Lcd.drawJpgFile(fs::FS &fs, const char *path, uint16_t x, uint16_t y); 65 | M5.Lcd.drawBmpFile(fs::FS &fs, const char *path, uint16_t x, uint16_t y); 66 | 67 | Button: 68 | M5.BtnA/B/C.read(); 69 | M5.BtnA/B/C.isPressed(); 70 | M5.BtnA/B/C.isReleased(); 71 | M5.BtnA/B/C.wasPressed(); 72 | M5.BtnA/B/C.wasReleased(); 73 | M5.BtnA/B/C.wasreleasedFor() 74 | M5.BtnA/B/C.pressedFor(uint32_t ms); 75 | M5.BtnA/B/C.releasedFor(uint32_t ms); 76 | M5.BtnA/B/C.lastChange(); 77 | 78 | Speaker: 79 | M5.Speaker.tone(uint32_t freq); 80 | M5.Speaker.tone(freq, time); 81 | M5.Speaker.beep(); 82 | M5.Speaker.setBeep(uint16_t frequency, uint16_t duration); 83 | M5.Speaker.mute(); 84 | 85 | * 86 | * \par History: 87 | *
 88 |  * ``         `
92 | * 93 | */ 94 | // #define ESP32 95 | 96 | #ifndef _M5STACK_H_ 97 | #define _M5STACK_H_ 98 | 99 | #if defined(ESP32) 100 | 101 | #include "gitTagVersion.h" 102 | #include 103 | #include 104 | #include 105 | #include "FS.h" 106 | #include "SD.h" 107 | 108 | #include "M5Display.h" 109 | #include "utility/Config.h" 110 | #include "utility/Button.h" 111 | #include "utility/Speaker.h" 112 | #include "utility/Power.h" 113 | #include "utility/CommUtil.h" 114 | 115 | #if defined(M5STACK_MPU6886) || defined(M5STACK_MPU9250) || defined(M5STACK_MPU6050) 116 | #include "utility/MPU6886.h" 117 | #elif defined M5STACK_200Q 118 | #include "utility/SH200Q.h" 119 | #endif 120 | 121 | class M5Stack 122 | { 123 | public: 124 | M5Stack(); 125 | void begin(bool LCDEnable = true, bool SDEnable = true, bool SerialEnable = true, bool I2CEnable = false); 126 | void update(); 127 | 128 | // Button API 129 | #define DEBOUNCE_MS 10 130 | Button BtnA = Button(BUTTON_A_PIN, true, DEBOUNCE_MS); 131 | Button BtnB = Button(BUTTON_B_PIN, true, DEBOUNCE_MS); 132 | Button BtnC = Button(BUTTON_C_PIN, true, DEBOUNCE_MS); 133 | 134 | // SPEAKER 135 | SPEAKER Speaker; 136 | 137 | // LCD 138 | M5Display Lcd = M5Display(); 139 | 140 | //Power 141 | POWER Power; 142 | 143 | // UART 144 | // HardwareSerial Serial0 = HardwareSerial(0); 145 | // HardwareSerial Serial2 = HardwareSerial(2); 146 | 147 | #if defined(M5STACK_MPU6886) || defined(M5STACK_MPU9250) || defined(M5STACK_MPU6050) 148 | MPU6886 IMU = MPU6886(); 149 | #elif defined M5STACK_200Q 150 | SH200Q IMU = SH200Q(); 151 | #endif 152 | 153 | // I2C 154 | CommUtil I2C = CommUtil(); 155 | 156 | /** 157 | * Function has been move to Power class.(for compatibility) 158 | * This name will be removed in a future release. 159 | */ 160 | void setPowerBoostKeepOn(bool en) __attribute__((deprecated)); 161 | void setWakeupButton(uint8_t button) __attribute__((deprecated)); 162 | void powerOFF() __attribute__((deprecated)); 163 | 164 | private: 165 | bool isInited; 166 | }; 167 | 168 | extern M5Stack M5; 169 | #define m5 M5 170 | #define lcd Lcd 171 | #else 172 | #error “This library only supports boards with ESP32 processor.” 173 | #endif 174 | #endif 175 | -------------------------------------------------------------------------------- /lib/src/utility/SH200Q.cpp: -------------------------------------------------------------------------------- 1 | #include "SH200Q.h" 2 | #include 3 | #include 4 | #include "MahonyAHRS.h" 5 | #include "../M5Stack.h" 6 | 7 | SH200Q::SH200Q() { 8 | 9 | } 10 | 11 | void SH200Q::I2C_Read_NBytes(uint8_t driver_Addr, uint8_t start_Addr, uint8_t number_Bytes, uint8_t *read_Buffer){ 12 | M5.I2C.readBytes(driver_Addr, start_Addr, number_Bytes, read_Buffer); 13 | } 14 | 15 | void SH200Q::I2C_Write_NBytes(uint8_t driver_Addr, uint8_t start_Addr, uint8_t number_Bytes, uint8_t *write_Buffer) { 16 | M5.I2C.writeBytes(driver_Addr, start_Addr, write_Buffer, number_Bytes); 17 | } 18 | 19 | void SH200Q::sh200i_ADCReset(void) { 20 | unsigned char tempdata[1]; 21 | //set 0xC2 bit2 1-->0 22 | I2C_Read_NBytes(SH200I_ADDRESS, SH200I_ADC_RESET, 1, tempdata); 23 | 24 | tempdata[0] = tempdata[0] | 0x04; 25 | I2C_Write_NBytes(SH200I_ADDRESS, SH200I_ADC_RESET, 1, tempdata); 26 | delay(1); 27 | 28 | tempdata[0] = tempdata[0] & 0xFB; 29 | //tempdata[0] = 0x0A; //C8 30 | I2C_Write_NBytes(SH200I_ADDRESS, SH200I_ADC_RESET, 1, tempdata); 31 | } 32 | 33 | void SH200Q::sh200i_Reset(void) { 34 | unsigned char tempdata[1]; 35 | 36 | I2C_Read_NBytes(SH200I_ADDRESS, SH200I_RESET, 1, tempdata); 37 | 38 | //SH200I_RESET 39 | tempdata[0] = tempdata[0] | 0x80; 40 | I2C_Write_NBytes(SH200I_ADDRESS, SH200I_RESET, 1, tempdata); 41 | 42 | delay(1); 43 | 44 | tempdata[0] = tempdata[0] & 0x7F; 45 | I2C_Write_NBytes(SH200I_ADDRESS, SH200I_RESET, 1, tempdata); 46 | } 47 | 48 | 49 | 50 | 51 | //初始化 52 | int SH200Q::Init(void) { 53 | unsigned char tempdata[1]; 54 | Gyscale = GFS_2000DPS; 55 | Acscale = AFS_8G; 56 | 57 | I2C_Read_NBytes(SH200I_ADDRESS, SH200I_WHOAMI, 1, tempdata); 58 | if(tempdata[0] != 0x18){ 59 | return -1; 60 | } 61 | imuId = tempdata[0]; 62 | 63 | sh200i_ADCReset(); 64 | 65 | I2C_Read_NBytes(SH200I_ADDRESS, 0xD8, 1, tempdata); 66 | 67 | tempdata[0] = tempdata[0] | 0x80; 68 | I2C_Write_NBytes(SH200I_ADDRESS, 0xD8, 1, tempdata); 69 | 70 | delay(1); 71 | 72 | tempdata[0] = tempdata[0] & 0x7F; 73 | I2C_Write_NBytes(SH200I_ADDRESS, 0xD8, 1, tempdata); 74 | 75 | tempdata[0] = 0x61; 76 | I2C_Write_NBytes(SH200I_ADDRESS, 0x78, 1, tempdata); 77 | 78 | delay(1); 79 | 80 | tempdata[0] = 0x00; 81 | I2C_Write_NBytes(SH200I_ADDRESS, 0x78, 1, tempdata); 82 | 83 | //set acc odr 256hz 84 | tempdata[0] = 0x91; //0x81 1024hz //0x89 512hz //0x91 256hz 85 | I2C_Write_NBytes(SH200I_ADDRESS, SH200I_ACC_CONFIG, 1, tempdata); 86 | 87 | //set gyro odr 500hz 88 | tempdata[0] = 0x13; //0x11 1000hz //0x13 500hz //0x15 256hz 89 | I2C_Write_NBytes(SH200I_ADDRESS, SH200I_GYRO_CONFIG, 1, tempdata); 90 | 91 | //set gyro dlpf 50hz 92 | tempdata[0] = 0x03; //0x00 250hz //0x01 200hz 0x02 100hz 0x03 50hz 0x04 25hz 93 | I2C_Write_NBytes(SH200I_ADDRESS, SH200I_GYRO_DLPF, 1, tempdata); 94 | 95 | //set no buffer mode 96 | tempdata[0] = 0x00; 97 | I2C_Write_NBytes(SH200I_ADDRESS, SH200I_FIFO_CONFIG, 1, tempdata); 98 | 99 | //set acc range +-8G 100 | tempdata[0] = 0x01; 101 | I2C_Write_NBytes(SH200I_ADDRESS, SH200I_ACC_RANGE, 1, tempdata); 102 | 103 | //set gyro range +-2000¶È/s 104 | tempdata[0] = 0x00; 105 | I2C_Write_NBytes(SH200I_ADDRESS, SH200I_GYRO_RANGE, 1, tempdata); 106 | 107 | tempdata[0] = 0xC0; 108 | I2C_Write_NBytes(SH200I_ADDRESS, SH200I_REG_SET1, 1, tempdata); 109 | 110 | I2C_Read_NBytes(SH200I_ADDRESS, SH200I_REG_SET2, 1, tempdata); 111 | 112 | //ADC Reset 113 | tempdata[0] = tempdata[0] | 0x10; 114 | I2C_Write_NBytes(SH200I_ADDRESS, SH200I_REG_SET2, 1, tempdata); 115 | 116 | delay(1); 117 | 118 | tempdata[0] = tempdata[0] & 0xEF; 119 | I2C_Write_NBytes(SH200I_ADDRESS, SH200I_REG_SET2, 1, tempdata); 120 | 121 | delay(10); 122 | 123 | setGyroFsr(Gyscale); 124 | setAccelFsr(Acscale); 125 | return 0; 126 | } 127 | 128 | 129 | // Possible gyro scales (and their register bit settings) are: 130 | // 250 DPS (00), 500 DPS (01), 1000 DPS (10), and 2000 DPS (11). 131 | // Here's a bit of an algorith to calculate DPS/(ADC tick) based on that 2-bit value: 132 | void SH200Q::updateGres() { 133 | switch (Gyscale) { 134 | case GFS_125DPS: 135 | gRes = 125.0/32768.0; 136 | break; 137 | case GFS_250DPS: 138 | gRes = 250.0/32768.0; 139 | break; 140 | case GFS_500DPS: 141 | gRes = 500.0/32768.0; 142 | break; 143 | case GFS_1000DPS: 144 | gRes = 1000.0/32768.0; 145 | break; 146 | case GFS_2000DPS: 147 | gRes = 2000.0/32768.0; 148 | break; 149 | } 150 | } 151 | 152 | // Possible accelerometer scales (and their register bit settings) are: 153 | // 2 Gs (00), 4 Gs (01), 8 Gs (10), and 16 Gs (11). 154 | // Here's a bit of an algorith to calculate DPS/(ADC tick) based on that 2-bit value: 155 | void SH200Q::updateAres() { 156 | switch (Acscale) { 157 | case AFS_4G: 158 | aRes = 4.0/32768.0; 159 | break; 160 | case AFS_8G: 161 | aRes = 8.0/32768.0; 162 | break; 163 | case AFS_16G: 164 | aRes = 16.0/32768.0; 165 | break; 166 | } 167 | } 168 | 169 | void SH200Q::setGyroFsr(Gscale scale) { 170 | uint8_t regData; 171 | I2C_Read_NBytes(SH200I_ADDRESS, SH200I_GYRO_RANGE, 1, ®Data); 172 | regData = (regData & 0xf8) | (scale & 0x07); 173 | I2C_Write_NBytes(SH200I_ADDRESS, SH200I_GYRO_RANGE, 1, ®Data); 174 | delay(10); 175 | Gyscale = scale; 176 | updateGres(); 177 | } 178 | 179 | void SH200Q::setAccelFsr(Ascale scale) { 180 | uint8_t regData; 181 | I2C_Read_NBytes(SH200I_ADDRESS, SH200I_ACC_RANGE, 1, ®Data); 182 | regData = (regData & 0xf8) | (scale & 0x07); 183 | I2C_Write_NBytes(SH200I_ADDRESS, SH200I_ACC_RANGE, 1, ®Data); 184 | delay(10); 185 | Acscale = scale; 186 | updateAres(); 187 | } 188 | 189 | void SH200Q::getAccelAdc(int16_t* ax, int16_t* ay, int16_t* az) { 190 | uint8_t buf[6]; 191 | I2C_Read_NBytes(SH200I_ADDRESS,SH200I_OUTPUT_ACC,6,buf); 192 | 193 | *ax=(int16_t)((buf[1]<<8)|buf[0]); 194 | *ay=(int16_t)((buf[3]<<8)|buf[2]); 195 | *az=(int16_t)((buf[5]<<8)|buf[4]); 196 | } 197 | 198 | void SH200Q::getAccelData(float* ax, float* ay, float* az) { 199 | uint8_t buf[6]; 200 | I2C_Read_NBytes(SH200I_ADDRESS,SH200I_OUTPUT_ACC,6,buf); 201 | 202 | *ax=(int16_t)((buf[1]<<8)|buf[0]) * aRes; 203 | *ay=(int16_t)((buf[3]<<8)|buf[2]) * aRes; 204 | *az=(int16_t)((buf[5]<<8)|buf[4]) * aRes; 205 | } 206 | 207 | void SH200Q::getGyroAdc(int16_t* gx, int16_t* gy, int16_t* gz) { 208 | uint8_t buf[6]; 209 | I2C_Read_NBytes(SH200I_ADDRESS,SH200I_OUTPUT_GYRO,6,buf); 210 | 211 | *gx=(int16_t)((buf[1]<<8)|buf[0]); 212 | *gy=(int16_t)((buf[3]<<8)|buf[2]); 213 | *gz=(int16_t)((buf[5]<<8)|buf[4]); 214 | } 215 | 216 | void SH200Q::getGyroData(float* gx, float* gy, float* gz) { 217 | uint8_t buf[6]; 218 | I2C_Read_NBytes(SH200I_ADDRESS,SH200I_OUTPUT_GYRO,6,buf); 219 | 220 | *gx=(int16_t)((buf[1]<<8)|buf[0]) * gRes; 221 | *gy=(int16_t)((buf[3]<<8)|buf[2]) * gRes; 222 | *gz=(int16_t)((buf[5]<<8)|buf[4]) * gRes; 223 | } 224 | 225 | void SH200Q::getTempAdc(int16_t *t) { 226 | uint8_t buf[2]; 227 | I2C_Read_NBytes(SH200I_ADDRESS,SH200I_OUTPUT_TEMP,2,buf); 228 | *t=(int16_t)((buf[1]<<8)|buf[0]); 229 | } 230 | 231 | void SH200Q::getTempData(float *t){ 232 | uint8_t buf[2]; 233 | I2C_Read_NBytes(SH200I_ADDRESS,SH200I_OUTPUT_TEMP,2,buf); 234 | *t=(int16_t)((buf[1]<<8)|buf[0]) / 333.87 + 21.0; 235 | } 236 | 237 | //!俯仰,航向,横滚:pitch,yaw,roll,指三维空间中飞行器的旋转状态。 238 | void SH200Q::getAhrsData(float *pitch, float *roll, float *yaw) { 239 | 240 | float accX = 0; 241 | float accY = 0; 242 | float accZ = 0; 243 | 244 | float gyroX = 0; 245 | float gyroY = 0; 246 | float gyroZ = 0; 247 | 248 | 249 | getGyroData(&gyroX, &gyroY, &gyroZ); 250 | getAccelData(&accX, &accY, &accZ); 251 | 252 | MahonyAHRSupdateIMU(gyroX * DEG_TO_RAD, gyroY * DEG_TO_RAD, gyroZ * DEG_TO_RAD, accX, accY, accZ, pitch, roll, yaw); 253 | } 254 | -------------------------------------------------------------------------------- /lib/src/utility/Sprite.h: -------------------------------------------------------------------------------- 1 | #ifndef _SPRITE_H_ 2 | #define _SPRITE_H_ 3 | 4 | /*************************************************************************************** 5 | // The following class creates Sprites in RAM, graphics can then be drawn in the Sprite 6 | // and rendered quickly onto the TFT screen. The class inherits the graphics functions 7 | // from the TFT_eSPI class. Some functions are overridden by this class so that the 8 | // graphics are written to the Sprite rather than the TFT. 9 | ***************************************************************************************/ 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | #include "In_eSPI.h" 16 | 17 | typedef enum { 18 | JPEG_DIV_ESPRITE_NONE, 19 | JPEG_DIV_ESPRITE_2, 20 | JPEG_DIV_ESPRITE_4, 21 | JPEG_DIV_ESPRITE_8, 22 | JPEG_DIV_ESPRITE_MAX 23 | } jpeg_div_eSprite_t; 24 | 25 | class TFT_eSprite : public TFT_eSPI { 26 | 27 | public: 28 | 29 | TFT_eSprite(TFT_eSPI *tft); 30 | 31 | // Create a sprite of width x height pixels, return a pointer to the RAM area 32 | // Sketch can cast returned value to (uint16_t*) for 16 bit depth if needed 33 | // RAM required is 1 byte per pixel for 8 bit colour depth, 2 bytes for 16 bit 34 | void* createSprite(int16_t width, int16_t height, uint8_t frames = 1); 35 | 36 | // Delete the sprite to free up the RAM 37 | void deleteSprite(void); 38 | 39 | // Select the frame buffer for graphics 40 | void* frameBuffer(int8_t f); 41 | 42 | // Set or get the colour depth to 8 or 16 bits. Can be used to change depth an existing 43 | // sprite, but clears it to black, returns a new pointer if sprite is re-created. 44 | void* setColorDepth(int8_t b); 45 | int8_t getColorDepth(void); 46 | 47 | void setBitmapColor(uint16_t c, uint16_t b); 48 | 49 | void drawPixel(int32_t x, int32_t y, uint32_t color); 50 | 51 | void drawChar(int32_t x, int32_t y, uint16_t c, uint32_t color, uint32_t bg, uint8_t size), 52 | 53 | fillSprite(uint32_t color), 54 | fillScreen(uint32_t color), 55 | 56 | // Define a window to push 16 bit colour pixels into in a raster order 57 | // Colours are converted to 8 bit if depth is set to 8 58 | setWindow(int32_t x0, int32_t y0, int32_t x1, int32_t y1), 59 | pushColor(uint32_t color), 60 | pushColor(uint32_t color, uint16_t len), 61 | pushEmptyColor(), 62 | // Push a pixel preformatted as a 8 or 16 bit colour (avoids conversion overhead) 63 | writeColor(uint16_t color), 64 | writeColors(uint16_t* color, uint16_t len), 65 | 66 | // Set the scroll zone, top left corner at x,y with defined width and height 67 | // The colour (optional, black is default) is used to fill the gap after the scroll 68 | setScrollRect(int32_t x, int32_t y, int32_t w, int32_t h, uint16_t color = TFT_BLACK), 69 | // Scroll the defined zone dx,dy pixels. Negative values left,up, positive right,down 70 | // dy is optional (default is then no up/down scroll). 71 | // The sprite coordinate frame does not move because pixels are moved 72 | scroll(int16_t dx, int16_t dy = 0), 73 | 74 | drawLine(int32_t x0, int32_t y0, int32_t x1, int32_t y1, uint32_t color), 75 | drawFastVLine(int32_t x, int32_t y, int32_t h, uint32_t color), 76 | drawFastHLine(int32_t x, int32_t y, int32_t w, uint32_t color), 77 | 78 | fillRect(int32_t x, int32_t y, int32_t w, int32_t h, uint32_t color); 79 | 80 | // Set the sprite text cursor position for print class (does not change the TFT screen cursor) 81 | //setCursor(int16_t x, int16_t y); 82 | 83 | // Set the rotation of the Sprite (for 1bpp Sprites only) 84 | void setRotation(uint8_t rotation); 85 | uint8_t getRotation(void); 86 | void getSprite2Buff( uint16_t *ptr, int32_t x, int32_t y, int32_t w, int32_t h); 87 | 88 | // Push a rotated copy of Sprite to TFT with optional transparent colour 89 | bool pushRotated(int16_t angle, int32_t transp = -1); 90 | // Push a rotated copy of Sprite to another different Sprite with optional transparent colour 91 | bool pushRotated(TFT_eSprite *spr, int16_t angle, int32_t transp = -1); 92 | // Set and get the pivot point for this Sprite 93 | void setPivot(int16_t x, int16_t y); 94 | int16_t getPivotX(void), 95 | getPivotY(void); 96 | 97 | // Get the bounding box for a rotated copy of this Sprite 98 | void getRotatedBounds(float sina, float cosa, int16_t w, int16_t h, int16_t xp, int16_t yp, 99 | int16_t *min_x, int16_t *min_y, int16_t *max_x, int16_t *max_y); 100 | 101 | // Read the colour of a pixel at x,y and return value in 565 format 102 | uint16_t readPixel(int32_t x0, int32_t y0); 103 | 104 | // Write an image (colour bitmap) to the sprite 105 | void pushImage(int32_t x0, int32_t y0, int32_t w, int32_t h, uint16_t *data); 106 | void pushImage(int32_t x0, int32_t y0, int32_t w, int32_t h, const uint16_t *data); 107 | void pushInSprite(TFT_eSprite *spr,int32_t srcX, int32_t srcY, int32_t srcW, int32_t srcH, 108 | int32_t desX, int32_t desY); 109 | 110 | 111 | void drawColorBitmap(int32_t x0, int32_t y0, int32_t w, int32_t h,const uint8_t *data, uint32_t color, uint32_t bkcolor); 112 | void drawColorBitmapAlpha(int32_t x0, int32_t y0, int32_t w, int32_t h,const uint8_t *data, uint32_t color, uint32_t bkcolor); 113 | 114 | // Swap the byte order for pushImage() - corrects different image endianness 115 | void setSwapBytes(bool swap); 116 | bool getSwapBytes(void); 117 | 118 | // Push the sprite to the TFT screen, this fn calls pushImage() in the TFT class. 119 | // Optionally a "transparent" colour can be defined, pixels of that colour will not be rendered 120 | void pushSprite(int32_t x, int32_t y); 121 | void pushSprite(int32_t x, int32_t y, uint16_t transparent); 122 | 123 | int16_t drawChar(uint16_t uniCode, int32_t x, int32_t y, uint8_t font), 124 | drawChar(uint16_t uniCode, int32_t x, int32_t y); 125 | 126 | // Return the width and height of the sprite 127 | int16_t width(void), 128 | height(void); 129 | 130 | // Used by print class to print text to cursor position 131 | size_t write(uint8_t); 132 | 133 | // Functions associated with anti-aliased fonts 134 | void drawGlyph(uint16_t code); 135 | void printToSprite(String string); 136 | void printToSprite(char *cbuffer, uint16_t len); 137 | int16_t printToSprite(int16_t x, int16_t y, uint16_t index); 138 | void setPsram( bool enabled ); 139 | 140 | 141 | void drawJpg(const uint8_t *jpg_data, size_t jpg_len, uint16_t x = 0, 142 | uint16_t y = 0, uint16_t maxWidth = 0, uint16_t maxHeight = 0, 143 | uint16_t offX = 0, uint16_t offY = 0, 144 | jpeg_div_eSprite_t scale = JPEG_DIV_ESPRITE_NONE); 145 | 146 | void drawJpgFile(fs::FS &fs, const char *path, uint16_t x = 0, uint16_t y = 0, 147 | uint16_t maxWidth = 0, uint16_t maxHeight = 0, 148 | uint16_t offX = 0, uint16_t offY = 0, 149 | jpeg_div_eSprite_t scale = JPEG_DIV_ESPRITE_NONE); 150 | 151 | private: 152 | 153 | TFT_eSPI *_tft; 154 | 155 | // Reserve memory for the Sprite and return a pointer 156 | void* callocSprite(int16_t width, int16_t height, uint8_t frames = 1); 157 | 158 | protected: 159 | 160 | uint8_t _bpp; // bits per pixel (1, 8 or 16) 161 | uint16_t *_img; // pointer to 16 bit sprite 162 | uint8_t *_img8; // pointer to 8 bit sprite 163 | uint8_t *_img8_1; // pointer to frame 1 164 | uint8_t *_img8_2; // pointer to frame 2 165 | 166 | int16_t _xpivot; // x pivot point coordinate 167 | int16_t _ypivot; // y pivot point coordinate 168 | 169 | bool _created; // A Sprite has been created and memory reserved 170 | bool _gFont = false; 171 | bool _usePsram = true; // use Psram if available 172 | 173 | // int32_t _icursor_x, _icursor_y; 174 | uint8_t _rotation = 0; 175 | int32_t _xs, _ys, _xe, _ye, _xptr, _yptr; // for setWindow 176 | int32_t _sx, _sy; // x,y for scroll zone 177 | uint32_t _sw, _sh; // w,h for scroll zone 178 | uint32_t _scolor; // gap fill colour for scroll zone 179 | 180 | boolean _iswapBytes; // Swap the byte order for Sprite pushImage() 181 | 182 | int32_t _iwidth, _iheight; // Sprite memory image bit width and height (swapped during rotations) 183 | int32_t _dwidth, _dheight; // Real display width and height (for <8bpp Sprites) 184 | int32_t _bitwidth; // Sprite image bit width for drawPixel (for <8bpp Sprites, not swapped) 185 | 186 | }; 187 | 188 | #endif -------------------------------------------------------------------------------- /lib/src/Fonts/glcdfont.c: -------------------------------------------------------------------------------- 1 | // Original Adafruit_GFX 5x7 font 2 | 3 | #ifndef FONT5X7_H 4 | #define FONT5X7_H 5 | 6 | #include 7 | 8 | // Standard ASCII 5x7 font 9 | 10 | static const unsigned char font[] PROGMEM = { 11 | 0x00, 0x00, 0x00, 0x00, 0x00, 12 | 0x3E, 0x5B, 0x4F, 0x5B, 0x3E, 13 | 0x3E, 0x6B, 0x4F, 0x6B, 0x3E, 14 | 0x1C, 0x3E, 0x7C, 0x3E, 0x1C, 15 | 0x18, 0x3C, 0x7E, 0x3C, 0x18, 16 | 0x1C, 0x57, 0x7D, 0x57, 0x1C, 17 | 0x1C, 0x5E, 0x7F, 0x5E, 0x1C, 18 | 0x00, 0x18, 0x3C, 0x18, 0x00, 19 | 0xFF, 0xE7, 0xC3, 0xE7, 0xFF, 20 | 0x00, 0x18, 0x24, 0x18, 0x00, 21 | 0xFF, 0xE7, 0xDB, 0xE7, 0xFF, 22 | 0x30, 0x48, 0x3A, 0x06, 0x0E, 23 | 0x26, 0x29, 0x79, 0x29, 0x26, 24 | 0x40, 0x7F, 0x05, 0x05, 0x07, 25 | 0x40, 0x7F, 0x05, 0x25, 0x3F, 26 | 0x5A, 0x3C, 0xE7, 0x3C, 0x5A, 27 | 0x7F, 0x3E, 0x1C, 0x1C, 0x08, 28 | 0x08, 0x1C, 0x1C, 0x3E, 0x7F, 29 | 0x14, 0x22, 0x7F, 0x22, 0x14, 30 | 0x5F, 0x5F, 0x00, 0x5F, 0x5F, 31 | 0x06, 0x09, 0x7F, 0x01, 0x7F, 32 | 0x00, 0x66, 0x89, 0x95, 0x6A, 33 | 0x60, 0x60, 0x60, 0x60, 0x60, 34 | 0x94, 0xA2, 0xFF, 0xA2, 0x94, 35 | 0x08, 0x04, 0x7E, 0x04, 0x08, 36 | 0x10, 0x20, 0x7E, 0x20, 0x10, 37 | 0x08, 0x08, 0x2A, 0x1C, 0x08, 38 | 0x08, 0x1C, 0x2A, 0x08, 0x08, 39 | 0x1E, 0x10, 0x10, 0x10, 0x10, 40 | 0x0C, 0x1E, 0x0C, 0x1E, 0x0C, 41 | 0x30, 0x38, 0x3E, 0x38, 0x30, 42 | 0x06, 0x0E, 0x3E, 0x0E, 0x06, 43 | 0x00, 0x00, 0x00, 0x00, 0x00, 44 | 0x00, 0x00, 0x5F, 0x00, 0x00, 45 | 0x00, 0x07, 0x00, 0x07, 0x00, 46 | 0x14, 0x7F, 0x14, 0x7F, 0x14, 47 | 0x24, 0x2A, 0x7F, 0x2A, 0x12, 48 | 0x23, 0x13, 0x08, 0x64, 0x62, 49 | 0x36, 0x49, 0x56, 0x20, 0x50, 50 | 0x00, 0x08, 0x07, 0x03, 0x00, 51 | 0x00, 0x1C, 0x22, 0x41, 0x00, 52 | 0x00, 0x41, 0x22, 0x1C, 0x00, 53 | 0x2A, 0x1C, 0x7F, 0x1C, 0x2A, 54 | 0x08, 0x08, 0x3E, 0x08, 0x08, 55 | 0x00, 0x80, 0x70, 0x30, 0x00, 56 | 0x08, 0x08, 0x08, 0x08, 0x08, 57 | 0x00, 0x00, 0x60, 0x60, 0x00, 58 | 0x20, 0x10, 0x08, 0x04, 0x02, 59 | 0x3E, 0x51, 0x49, 0x45, 0x3E, 60 | 0x00, 0x42, 0x7F, 0x40, 0x00, 61 | 0x72, 0x49, 0x49, 0x49, 0x46, 62 | 0x21, 0x41, 0x49, 0x4D, 0x33, 63 | 0x18, 0x14, 0x12, 0x7F, 0x10, 64 | 0x27, 0x45, 0x45, 0x45, 0x39, 65 | 0x3C, 0x4A, 0x49, 0x49, 0x31, 66 | 0x41, 0x21, 0x11, 0x09, 0x07, 67 | 0x36, 0x49, 0x49, 0x49, 0x36, 68 | 0x46, 0x49, 0x49, 0x29, 0x1E, 69 | 0x00, 0x00, 0x14, 0x00, 0x00, 70 | 0x00, 0x40, 0x34, 0x00, 0x00, 71 | 0x00, 0x08, 0x14, 0x22, 0x41, 72 | 0x14, 0x14, 0x14, 0x14, 0x14, 73 | 0x00, 0x41, 0x22, 0x14, 0x08, 74 | 0x02, 0x01, 0x59, 0x09, 0x06, 75 | 0x3E, 0x41, 0x5D, 0x59, 0x4E, 76 | 0x7C, 0x12, 0x11, 0x12, 0x7C, 77 | 0x7F, 0x49, 0x49, 0x49, 0x36, 78 | 0x3E, 0x41, 0x41, 0x41, 0x22, 79 | 0x7F, 0x41, 0x41, 0x41, 0x3E, 80 | 0x7F, 0x49, 0x49, 0x49, 0x41, 81 | 0x7F, 0x09, 0x09, 0x09, 0x01, 82 | 0x3E, 0x41, 0x41, 0x51, 0x73, 83 | 0x7F, 0x08, 0x08, 0x08, 0x7F, 84 | 0x00, 0x41, 0x7F, 0x41, 0x00, 85 | 0x20, 0x40, 0x41, 0x3F, 0x01, 86 | 0x7F, 0x08, 0x14, 0x22, 0x41, 87 | 0x7F, 0x40, 0x40, 0x40, 0x40, 88 | 0x7F, 0x02, 0x1C, 0x02, 0x7F, 89 | 0x7F, 0x04, 0x08, 0x10, 0x7F, 90 | 0x3E, 0x41, 0x41, 0x41, 0x3E, 91 | 0x7F, 0x09, 0x09, 0x09, 0x06, 92 | 0x3E, 0x41, 0x51, 0x21, 0x5E, 93 | 0x7F, 0x09, 0x19, 0x29, 0x46, 94 | 0x26, 0x49, 0x49, 0x49, 0x32, 95 | 0x03, 0x01, 0x7F, 0x01, 0x03, 96 | 0x3F, 0x40, 0x40, 0x40, 0x3F, 97 | 0x1F, 0x20, 0x40, 0x20, 0x1F, 98 | 0x3F, 0x40, 0x38, 0x40, 0x3F, 99 | 0x63, 0x14, 0x08, 0x14, 0x63, 100 | 0x03, 0x04, 0x78, 0x04, 0x03, 101 | 0x61, 0x59, 0x49, 0x4D, 0x43, 102 | 0x00, 0x7F, 0x41, 0x41, 0x41, 103 | 0x02, 0x04, 0x08, 0x10, 0x20, 104 | 0x00, 0x41, 0x41, 0x41, 0x7F, 105 | 0x04, 0x02, 0x01, 0x02, 0x04, 106 | 0x40, 0x40, 0x40, 0x40, 0x40, 107 | 0x00, 0x03, 0x07, 0x08, 0x00, 108 | 0x20, 0x54, 0x54, 0x78, 0x40, 109 | 0x7F, 0x28, 0x44, 0x44, 0x38, 110 | 0x38, 0x44, 0x44, 0x44, 0x28, 111 | 0x38, 0x44, 0x44, 0x28, 0x7F, 112 | 0x38, 0x54, 0x54, 0x54, 0x18, 113 | 0x00, 0x08, 0x7E, 0x09, 0x02, 114 | 0x18, 0xA4, 0xA4, 0x9C, 0x78, 115 | 0x7F, 0x08, 0x04, 0x04, 0x78, 116 | 0x00, 0x44, 0x7D, 0x40, 0x00, 117 | 0x20, 0x40, 0x40, 0x3D, 0x00, 118 | 0x7F, 0x10, 0x28, 0x44, 0x00, 119 | 0x00, 0x41, 0x7F, 0x40, 0x00, 120 | 0x7C, 0x04, 0x78, 0x04, 0x78, 121 | 0x7C, 0x08, 0x04, 0x04, 0x78, 122 | 0x38, 0x44, 0x44, 0x44, 0x38, 123 | 0xFC, 0x18, 0x24, 0x24, 0x18, 124 | 0x18, 0x24, 0x24, 0x18, 0xFC, 125 | 0x7C, 0x08, 0x04, 0x04, 0x08, 126 | 0x48, 0x54, 0x54, 0x54, 0x24, 127 | 0x04, 0x04, 0x3F, 0x44, 0x24, 128 | 0x3C, 0x40, 0x40, 0x20, 0x7C, 129 | 0x1C, 0x20, 0x40, 0x20, 0x1C, 130 | 0x3C, 0x40, 0x30, 0x40, 0x3C, 131 | 0x44, 0x28, 0x10, 0x28, 0x44, 132 | 0x4C, 0x90, 0x90, 0x90, 0x7C, 133 | 0x44, 0x64, 0x54, 0x4C, 0x44, 134 | 0x00, 0x08, 0x36, 0x41, 0x00, 135 | 0x00, 0x00, 0x77, 0x00, 0x00, 136 | 0x00, 0x41, 0x36, 0x08, 0x00, 137 | 0x02, 0x01, 0x02, 0x04, 0x02, 138 | 0x3C, 0x26, 0x23, 0x26, 0x3C, 139 | 0x1E, 0xA1, 0xA1, 0x61, 0x12, 140 | 0x3A, 0x40, 0x40, 0x20, 0x7A, 141 | 0x38, 0x54, 0x54, 0x55, 0x59, 142 | 0x21, 0x55, 0x55, 0x79, 0x41, 143 | 0x21, 0x54, 0x54, 0x78, 0x41, 144 | 0x21, 0x55, 0x54, 0x78, 0x40, 145 | 0x20, 0x54, 0x55, 0x79, 0x40, 146 | 0x0C, 0x1E, 0x52, 0x72, 0x12, 147 | 0x39, 0x55, 0x55, 0x55, 0x59, 148 | 0x39, 0x54, 0x54, 0x54, 0x59, 149 | 0x39, 0x55, 0x54, 0x54, 0x58, 150 | 0x00, 0x00, 0x45, 0x7C, 0x41, 151 | 0x00, 0x02, 0x45, 0x7D, 0x42, 152 | 0x00, 0x01, 0x45, 0x7C, 0x40, 153 | 0xF0, 0x29, 0x24, 0x29, 0xF0, 154 | 0xF0, 0x28, 0x25, 0x28, 0xF0, 155 | 0x7C, 0x54, 0x55, 0x45, 0x00, 156 | 0x20, 0x54, 0x54, 0x7C, 0x54, 157 | 0x7C, 0x0A, 0x09, 0x7F, 0x49, 158 | 0x32, 0x49, 0x49, 0x49, 0x32, 159 | 0x32, 0x48, 0x48, 0x48, 0x32, 160 | 0x32, 0x4A, 0x48, 0x48, 0x30, 161 | 0x3A, 0x41, 0x41, 0x21, 0x7A, 162 | 0x3A, 0x42, 0x40, 0x20, 0x78, 163 | 0x00, 0x9D, 0xA0, 0xA0, 0x7D, 164 | 0x39, 0x44, 0x44, 0x44, 0x39, 165 | 0x3D, 0x40, 0x40, 0x40, 0x3D, 166 | 0x3C, 0x24, 0xFF, 0x24, 0x24, 167 | 0x48, 0x7E, 0x49, 0x43, 0x66, 168 | 0x2B, 0x2F, 0xFC, 0x2F, 0x2B, 169 | 0xFF, 0x09, 0x29, 0xF6, 0x20, 170 | 0xC0, 0x88, 0x7E, 0x09, 0x03, 171 | 0x20, 0x54, 0x54, 0x79, 0x41, 172 | 0x00, 0x00, 0x44, 0x7D, 0x41, 173 | 0x30, 0x48, 0x48, 0x4A, 0x32, 174 | 0x38, 0x40, 0x40, 0x22, 0x7A, 175 | 0x00, 0x7A, 0x0A, 0x0A, 0x72, 176 | 0x7D, 0x0D, 0x19, 0x31, 0x7D, 177 | 0x26, 0x29, 0x29, 0x2F, 0x28, 178 | 0x26, 0x29, 0x29, 0x29, 0x26, 179 | 0x30, 0x48, 0x4D, 0x40, 0x20, 180 | 0x38, 0x08, 0x08, 0x08, 0x08, 181 | 0x08, 0x08, 0x08, 0x08, 0x38, 182 | 0x2F, 0x10, 0xC8, 0xAC, 0xBA, 183 | 0x2F, 0x10, 0x28, 0x34, 0xFA, 184 | 0x00, 0x00, 0x7B, 0x00, 0x00, 185 | 0x08, 0x14, 0x2A, 0x14, 0x22, 186 | 0x22, 0x14, 0x2A, 0x14, 0x08, 187 | 0xAA, 0x00, 0x55, 0x00, 0xAA, 188 | 0xAA, 0x55, 0xAA, 0x55, 0xAA, 189 | 0x00, 0x00, 0x00, 0xFF, 0x00, 190 | 0x10, 0x10, 0x10, 0xFF, 0x00, 191 | 0x14, 0x14, 0x14, 0xFF, 0x00, 192 | 0x10, 0x10, 0xFF, 0x00, 0xFF, 193 | 0x10, 0x10, 0xF0, 0x10, 0xF0, 194 | 0x14, 0x14, 0x14, 0xFC, 0x00, 195 | 0x14, 0x14, 0xF7, 0x00, 0xFF, 196 | 0x00, 0x00, 0xFF, 0x00, 0xFF, 197 | 0x14, 0x14, 0xF4, 0x04, 0xFC, 198 | 0x14, 0x14, 0x17, 0x10, 0x1F, 199 | 0x10, 0x10, 0x1F, 0x10, 0x1F, 200 | 0x14, 0x14, 0x14, 0x1F, 0x00, 201 | 0x10, 0x10, 0x10, 0xF0, 0x00, 202 | 0x00, 0x00, 0x00, 0x1F, 0x10, 203 | 0x10, 0x10, 0x10, 0x1F, 0x10, 204 | 0x10, 0x10, 0x10, 0xF0, 0x10, 205 | 0x00, 0x00, 0x00, 0xFF, 0x10, 206 | 0x10, 0x10, 0x10, 0x10, 0x10, 207 | 0x10, 0x10, 0x10, 0xFF, 0x10, 208 | 0x00, 0x00, 0x00, 0xFF, 0x14, 209 | 0x00, 0x00, 0xFF, 0x00, 0xFF, 210 | 0x00, 0x00, 0x1F, 0x10, 0x17, 211 | 0x00, 0x00, 0xFC, 0x04, 0xF4, 212 | 0x14, 0x14, 0x17, 0x10, 0x17, 213 | 0x14, 0x14, 0xF4, 0x04, 0xF4, 214 | 0x00, 0x00, 0xFF, 0x00, 0xF7, 215 | 0x14, 0x14, 0x14, 0x14, 0x14, 216 | 0x14, 0x14, 0xF7, 0x00, 0xF7, 217 | 0x14, 0x14, 0x14, 0x17, 0x14, 218 | 0x10, 0x10, 0x1F, 0x10, 0x1F, 219 | 0x14, 0x14, 0x14, 0xF4, 0x14, 220 | 0x10, 0x10, 0xF0, 0x10, 0xF0, 221 | 0x00, 0x00, 0x1F, 0x10, 0x1F, 222 | 0x00, 0x00, 0x00, 0x1F, 0x14, 223 | 0x00, 0x00, 0x00, 0xFC, 0x14, 224 | 0x00, 0x00, 0xF0, 0x10, 0xF0, 225 | 0x10, 0x10, 0xFF, 0x10, 0xFF, 226 | 0x14, 0x14, 0x14, 0xFF, 0x14, 227 | 0x10, 0x10, 0x10, 0x1F, 0x00, 228 | 0x00, 0x00, 0x00, 0xF0, 0x10, 229 | 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 230 | 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 231 | 0xFF, 0xFF, 0xFF, 0x00, 0x00, 232 | 0x00, 0x00, 0x00, 0xFF, 0xFF, 233 | 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 234 | 0x38, 0x44, 0x44, 0x38, 0x44, 235 | 0x7C, 0x2A, 0x2A, 0x3E, 0x14, 236 | 0x7E, 0x02, 0x02, 0x06, 0x06, 237 | 0x02, 0x7E, 0x02, 0x7E, 0x02, 238 | 0x63, 0x55, 0x49, 0x41, 0x63, 239 | 0x38, 0x44, 0x44, 0x3C, 0x04, 240 | 0x40, 0x7E, 0x20, 0x1E, 0x20, 241 | 0x06, 0x02, 0x7E, 0x02, 0x02, 242 | 0x99, 0xA5, 0xE7, 0xA5, 0x99, 243 | 0x1C, 0x2A, 0x49, 0x2A, 0x1C, 244 | 0x4C, 0x72, 0x01, 0x72, 0x4C, 245 | 0x30, 0x4A, 0x4D, 0x4D, 0x30, 246 | 0x30, 0x48, 0x78, 0x48, 0x30, 247 | 0xBC, 0x62, 0x5A, 0x46, 0x3D, 248 | 0x3E, 0x49, 0x49, 0x49, 0x00, 249 | 0x7E, 0x01, 0x01, 0x01, 0x7E, 250 | 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 251 | 0x44, 0x44, 0x5F, 0x44, 0x44, 252 | 0x40, 0x51, 0x4A, 0x44, 0x40, 253 | 0x40, 0x44, 0x4A, 0x51, 0x40, 254 | 0x00, 0x00, 0xFF, 0x01, 0x03, 255 | 0xE0, 0x80, 0xFF, 0x00, 0x00, 256 | 0x08, 0x08, 0x6B, 0x6B, 0x08, 257 | 0x36, 0x12, 0x36, 0x24, 0x36, 258 | 0x06, 0x0F, 0x09, 0x0F, 0x06, 259 | 0x00, 0x00, 0x18, 0x18, 0x00, 260 | 0x00, 0x00, 0x10, 0x10, 0x00, 261 | 0x30, 0x40, 0xFF, 0x01, 0x01, 262 | 0x00, 0x1F, 0x01, 0x01, 0x1E, 263 | 0x00, 0x19, 0x1D, 0x17, 0x12, 264 | 0x00, 0x3C, 0x3C, 0x3C, 0x3C, 265 | 0x00, 0x00, 0x00, 0x00, 0x00 266 | }; 267 | 268 | #endif // FONT5X7_H 269 | -------------------------------------------------------------------------------- /lib/src/utility/MahonyAHRS.cpp: -------------------------------------------------------------------------------- 1 | //===================================================================================================== 2 | // MahonyAHRS.c 3 | //===================================================================================================== 4 | // 5 | // Madgwick's implementation of Mayhony's AHRS algorithm. 6 | // See: http://www.x-io.co.uk/node/8#open_source_ahrs_and_imu_algorithms 7 | // 8 | // Date Author Notes 9 | // 29/09/2011 SOH Madgwick Initial release 10 | // 02/10/2011 SOH Madgwick Optimised for reduced CPU load 11 | // 12 | //===================================================================================================== 13 | 14 | //--------------------------------------------------------------------------------------------------- 15 | // Header files 16 | 17 | #include "MahonyAHRS.h" 18 | #include "Arduino.h" 19 | #include 20 | //--------------------------------------------------------------------------------------------------- 21 | // Definitions 22 | 23 | #define sampleFreq 25.0f // sample frequency in Hz 24 | #define twoKpDef (2.0f * 1.0f) // 2 * proportional gain 25 | #define twoKiDef (2.0f * 0.0f) // 2 * integral gain 26 | 27 | //#define twoKiDef (0.0f * 0.0f) 28 | 29 | //--------------------------------------------------------------------------------------------------- 30 | // Variable definitions 31 | 32 | volatile float twoKp = twoKpDef; // 2 * proportional gain (Kp) 33 | volatile float twoKi = twoKiDef; // 2 * integral gain (Ki) 34 | volatile float q0 = 1.0, q1 = 0.0, q2 = 0.0, q3 = 0.0; // quaternion of sensor frame relative to auxiliary frame 35 | volatile float integralFBx = 0.0f, integralFBy = 0.0f, integralFBz = 0.0f; // integral error terms scaled by Ki 36 | 37 | //--------------------------------------------------------------------------------------------------- 38 | // Function declarations 39 | 40 | //float invSqrt(float x); 41 | 42 | //==================================================================================================== 43 | // Functions 44 | 45 | //--------------------------------------------------------------------------------------------------- 46 | // AHRS algorithm update 47 | 48 | void MahonyAHRSupdate(float gx, float gy, float gz, float ax, float ay, float az, float mx, float my, float mz) { 49 | float recipNorm; 50 | float q0q0, q0q1, q0q2, q0q3, q1q1, q1q2, q1q3, q2q2, q2q3, q3q3; 51 | float hx, hy, bx, bz; 52 | float halfvx, halfvy, halfvz, halfwx, halfwy, halfwz; 53 | float halfex, halfey, halfez; 54 | float qa, qb, qc; 55 | 56 | // Use IMU algorithm if magnetometer measurement invalid (avoids NaN in magnetometer normalisation) 57 | if((mx == 0.0f) && (my == 0.0f) && (mz == 0.0f)) { 58 | //MahonyAHRSupdateIMU(gx, gy, gz, ax, ay, az); 59 | return; 60 | } 61 | 62 | // Compute feedback only if accelerometer measurement valid (avoids NaN in accelerometer normalisation) 63 | if(!((ax == 0.0f) && (ay == 0.0f) && (az == 0.0f))) { 64 | 65 | // Normalise accelerometer measurement 66 | recipNorm = sqrt(ax * ax + ay * ay + az * az); 67 | ax *= recipNorm; 68 | ay *= recipNorm; 69 | az *= recipNorm; 70 | 71 | // Normalise magnetometer measurement 72 | recipNorm = sqrt(mx * mx + my * my + mz * mz); 73 | mx *= recipNorm; 74 | my *= recipNorm; 75 | mz *= recipNorm; 76 | 77 | // Auxiliary variables to avoid repeated arithmetic 78 | q0q0 = q0 * q0; 79 | q0q1 = q0 * q1; 80 | q0q2 = q0 * q2; 81 | q0q3 = q0 * q3; 82 | q1q1 = q1 * q1; 83 | q1q2 = q1 * q2; 84 | q1q3 = q1 * q3; 85 | q2q2 = q2 * q2; 86 | q2q3 = q2 * q3; 87 | q3q3 = q3 * q3; 88 | 89 | // Reference direction of Earth's magnetic field 90 | hx = 2.0f * (mx * (0.5f - q2q2 - q3q3) + my * (q1q2 - q0q3) + mz * (q1q3 + q0q2)); 91 | hy = 2.0f * (mx * (q1q2 + q0q3) + my * (0.5f - q1q1 - q3q3) + mz * (q2q3 - q0q1)); 92 | bx = sqrt(hx * hx + hy * hy); 93 | bz = 2.0f * (mx * (q1q3 - q0q2) + my * (q2q3 + q0q1) + mz * (0.5f - q1q1 - q2q2)); 94 | 95 | // Estimated direction of gravity and magnetic field 96 | halfvx = q1q3 - q0q2; 97 | halfvy = q0q1 + q2q3; 98 | halfvz = q0q0 - 0.5f + q3q3; 99 | halfwx = bx * (0.5f - q2q2 - q3q3) + bz * (q1q3 - q0q2); 100 | halfwy = bx * (q1q2 - q0q3) + bz * (q0q1 + q2q3); 101 | halfwz = bx * (q0q2 + q1q3) + bz * (0.5f - q1q1 - q2q2); 102 | 103 | // Error is sum of cross product between estimated direction and measured direction of field vectors 104 | halfex = (ay * halfvz - az * halfvy) + (my * halfwz - mz * halfwy); 105 | halfey = (az * halfvx - ax * halfvz) + (mz * halfwx - mx * halfwz); 106 | halfez = (ax * halfvy - ay * halfvx) + (mx * halfwy - my * halfwx); 107 | 108 | // Compute and apply integral feedback if enabled 109 | if(twoKi > 0.0f) { 110 | integralFBx += twoKi * halfex * (1.0f / sampleFreq); // integral error scaled by Ki 111 | integralFBy += twoKi * halfey * (1.0f / sampleFreq); 112 | integralFBz += twoKi * halfez * (1.0f / sampleFreq); 113 | gx += integralFBx; // apply integral feedback 114 | gy += integralFBy; 115 | gz += integralFBz; 116 | } 117 | else { 118 | integralFBx = 0.0f; // prevent integral windup 119 | integralFBy = 0.0f; 120 | integralFBz = 0.0f; 121 | } 122 | 123 | // Apply proportional feedback 124 | gx += twoKp * halfex; 125 | gy += twoKp * halfey; 126 | gz += twoKp * halfez; 127 | } 128 | 129 | // Integrate rate of change of quaternion 130 | gx *= (0.5f * (1.0f / sampleFreq)); // pre-multiply common factors 131 | gy *= (0.5f * (1.0f / sampleFreq)); 132 | gz *= (0.5f * (1.0f / sampleFreq)); 133 | qa = q0; 134 | qb = q1; 135 | qc = q2; 136 | q0 += (-qb * gx - qc * gy - q3 * gz); 137 | q1 += (qa * gx + qc * gz - q3 * gy); 138 | q2 += (qa * gy - qb * gz + q3 * gx); 139 | q3 += (qa * gz + qb * gy - qc * gx); 140 | 141 | // Normalise quaternion 142 | recipNorm = sqrt(q0 * q0 + q1 * q1 + q2 * q2 + q3 * q3); 143 | q0 *= recipNorm; 144 | q1 *= recipNorm; 145 | q2 *= recipNorm; 146 | q3 *= recipNorm; 147 | } 148 | 149 | //--------------------------------------------------------------------------------------------------- 150 | // IMU algorithm update 151 | 152 | void MahonyAHRSupdateIMU(float gx, float gy, float gz, float ax, float ay, float az,float *pitch,float *roll,float *yaw) { 153 | float recipNorm; 154 | float halfvx, halfvy, halfvz; 155 | float halfex, halfey, halfez; 156 | float qa, qb, qc; 157 | 158 | 159 | // Compute feedback only if accelerometer measurement valid (avoids NaN in accelerometer normalisation) 160 | if(!((ax == 0.0f) && (ay == 0.0f) && (az == 0.0f))) { 161 | 162 | // Normalise accelerometer measurement 163 | recipNorm = invSqrt(ax * ax + ay * ay + az * az); 164 | ax *= recipNorm; 165 | ay *= recipNorm; 166 | az *= recipNorm; 167 | 168 | // Estimated direction of gravity and vector perpendicular to magnetic flux 169 | halfvx = q1 * q3 - q0 * q2; 170 | halfvy = q0 * q1 + q2 * q3; 171 | halfvz = q0 * q0 - 0.5f + q3 * q3; 172 | 173 | 174 | 175 | // Error is sum of cross product between estimated and measured direction of gravity 176 | halfex = (ay * halfvz - az * halfvy); 177 | halfey = (az * halfvx - ax * halfvz); 178 | halfez = (ax * halfvy - ay * halfvx); 179 | 180 | // Compute and apply integral feedback if enabled 181 | if(twoKi > 0.0f) { 182 | integralFBx += twoKi * halfex * (1.0f / sampleFreq); // integral error scaled by Ki 183 | integralFBy += twoKi * halfey * (1.0f / sampleFreq); 184 | integralFBz += twoKi * halfez * (1.0f / sampleFreq); 185 | gx += integralFBx; // apply integral feedback 186 | gy += integralFBy; 187 | gz += integralFBz; 188 | } 189 | else { 190 | integralFBx = 0.0f; // prevent integral windup 191 | integralFBy = 0.0f; 192 | integralFBz = 0.0f; 193 | } 194 | 195 | // Apply proportional feedback 196 | gx += twoKp * halfex; 197 | gy += twoKp * halfey; 198 | gz += twoKp * halfez; 199 | } 200 | 201 | // Integrate rate of change of quaternion 202 | gx *= (0.5f * (1.0f / sampleFreq)); // pre-multiply common factors 203 | gy *= (0.5f * (1.0f / sampleFreq)); 204 | gz *= (0.5f * (1.0f / sampleFreq)); 205 | qa = q0; 206 | qb = q1; 207 | qc = q2; 208 | q0 += (-qb * gx - qc * gy - q3 * gz); 209 | q1 += (qa * gx + qc * gz - q3 * gy); 210 | q2 += (qa * gy - qb * gz + q3 * gx); 211 | q3 += (qa * gz + qb * gy - qc * gx); 212 | 213 | // Normalise quaternion 214 | recipNorm = invSqrt(q0 * q0 + q1 * q1 + q2 * q2 + q3 * q3); 215 | q0 *= recipNorm; 216 | q1 *= recipNorm; 217 | q2 *= recipNorm; 218 | q3 *= recipNorm; 219 | 220 | 221 | *pitch = asin(-2 * q1 * q3 + 2 * q0* q2); // pitch 222 | *roll = atan2(2 * q2 * q3 + 2 * q0 * q1, -2 * q1 * q1 - 2 * q2* q2 + 1); // roll 223 | *yaw = atan2(2*(q1*q2 + q0*q3),q0*q0+q1*q1-q2*q2-q3*q3); //yaw 224 | 225 | *pitch *= RAD_TO_DEG; 226 | *yaw *= RAD_TO_DEG; 227 | // Declination of SparkFun Electronics (40°05'26.6"N 105°11'05.9"W) is 228 | // 8° 30' E ± 0° 21' (or 8.5°) on 2016-07-19 229 | // - http://www.ngdc.noaa.gov/geomag-web/#declination 230 | *yaw -= 8.5; 231 | *roll *= RAD_TO_DEG; 232 | 233 | ///Serial.printf("%f %f %f \r\n", pitch, roll, yaw); 234 | } 235 | 236 | //--------------------------------------------------------------------------------------------------- 237 | // Fast inverse square-root 238 | // See: http://en.wikipedia.org/wiki/Fast_inverse_square_root 239 | 240 | #pragma GCC diagnostic push 241 | #pragma GCC diagnostic ignored "-Wstrict-aliasing" 242 | float invSqrt(float x) { 243 | float halfx = 0.5f * x; 244 | float y = x; 245 | long i = *(long*)&y; 246 | i = 0x5f3759df - (i>>1); 247 | y = *(float*)&i; 248 | y = y * (1.5f - (halfx * y * y)); 249 | return y; 250 | } 251 | #pragma GCC diagnostic pop 252 | //==================================================================================================== 253 | // END OF CODE 254 | //==================================================================================================== 255 | -------------------------------------------------------------------------------- /lib/src/utility/MPU9250.h: -------------------------------------------------------------------------------- 1 | /* 2 | Note: The MPU9250 is an I2C sensor and uses the Arduino Wire library. 3 | Because the sensor is not 5V tolerant, we are using a 3.3 V 8 MHz Pro Mini or 4 | a 3.3 V Teensy 3.1. We have disabled the internal pull-ups used by the Wire 5 | library in the Wire.h/twi.c utility file. We are also using the 400 kHz fast 6 | I2C mode by setting the TWI_FREQ to 400000L /twi.h utility file. 7 | */ 8 | #ifndef _MPU9250_H_ 9 | #define _MPU9250_H_ 10 | 11 | #include 12 | #include 13 | 14 | // See also MPU-9250 Register Map and Descriptions, Revision 4.0, 15 | // RM-MPU-9250A-00, Rev. 1.4, 9/9/2013 for registers not listed in above 16 | // document; the MPU9250 and MPU9150 are virtually identical but the latter has 17 | // a different register map 18 | 19 | //Magnetometer Registers 20 | #define AK8963_ADDRESS 0x0C 21 | #define WHO_AM_I_AK8963 0x00 // should return 0x48 22 | #define INFO 0x01 23 | #define AK8963_ST1 0x02 // data ready status bit 0 24 | #define AK8963_XOUT_L 0x03 // data 25 | #define AK8963_XOUT_H 0x04 26 | #define AK8963_YOUT_L 0x05 27 | #define AK8963_YOUT_H 0x06 28 | #define AK8963_ZOUT_L 0x07 29 | #define AK8963_ZOUT_H 0x08 30 | #define AK8963_ST2 0x09 // Data overflow bit 3 and data read error status bit 2 31 | #define AK8963_CNTL 0x0A // Power down (0000), single-measurement (0001), self-test (1000) and Fuse ROM (1111) modes on bits 3:0 32 | #define AK8963_ASTC 0x0C // Self test control 33 | #define AK8963_I2CDIS 0x0F // I2C disable 34 | #define AK8963_ASAX 0x10 // Fuse ROM x-axis sensitivity adjustment value 35 | #define AK8963_ASAY 0x11 // Fuse ROM y-axis sensitivity adjustment value 36 | #define AK8963_ASAZ 0x12 // Fuse ROM z-axis sensitivity adjustment value 37 | 38 | #define SELF_TEST_X_GYRO 0x00 39 | #define SELF_TEST_Y_GYRO 0x01 40 | #define SELF_TEST_Z_GYRO 0x02 41 | 42 | /*#define X_FINE_GAIN 0x03 // [7:0] fine gain 43 | #define Y_FINE_GAIN 0x04 44 | #define Z_FINE_GAIN 0x05 45 | #define XA_OFFSET_H 0x06 // User-defined trim values for accelerometer 46 | #define XA_OFFSET_L_TC 0x07 47 | #define YA_OFFSET_H 0x08 48 | #define YA_OFFSET_L_TC 0x09 49 | #define ZA_OFFSET_H 0x0A 50 | #define ZA_OFFSET_L_TC 0x0B */ 51 | 52 | #define SELF_TEST_X_ACCEL 0x0D 53 | #define SELF_TEST_Y_ACCEL 0x0E 54 | #define SELF_TEST_Z_ACCEL 0x0F 55 | 56 | #define SELF_TEST_A 0x10 57 | 58 | #define XG_OFFSET_H 0x13 // User-defined trim values for gyroscope 59 | #define XG_OFFSET_L 0x14 60 | #define YG_OFFSET_H 0x15 61 | #define YG_OFFSET_L 0x16 62 | #define ZG_OFFSET_H 0x17 63 | #define ZG_OFFSET_L 0x18 64 | #define SMPLRT_DIV 0x19 65 | #define CONFIG 0x1A 66 | #define GYRO_CONFIG 0x1B 67 | #define ACCEL_CONFIG 0x1C 68 | #define ACCEL_CONFIG2 0x1D 69 | #define LP_ACCEL_ODR 0x1E 70 | #define WOM_THR 0x1F 71 | 72 | // Duration counter threshold for motion interrupt generation, 1 kHz rate, 73 | // LSB = 1 ms 74 | #define MOT_DUR 0x20 75 | // Zero-motion detection threshold bits [7:0] 76 | #define ZMOT_THR 0x21 77 | // Duration counter threshold for zero motion interrupt generation, 16 Hz rate, 78 | // LSB = 64 ms 79 | #define ZRMOT_DUR 0x22 80 | 81 | #define FIFO_EN 0x23 82 | #define I2C_MST_CTRL 0x24 83 | #define I2C_SLV0_ADDR 0x25 84 | #define I2C_SLV0_REG 0x26 85 | #define I2C_SLV0_CTRL 0x27 86 | #define I2C_SLV1_ADDR 0x28 87 | #define I2C_SLV1_REG 0x29 88 | #define I2C_SLV1_CTRL 0x2A 89 | #define I2C_SLV2_ADDR 0x2B 90 | #define I2C_SLV2_REG 0x2C 91 | #define I2C_SLV2_CTRL 0x2D 92 | #define I2C_SLV3_ADDR 0x2E 93 | #define I2C_SLV3_REG 0x2F 94 | #define I2C_SLV3_CTRL 0x30 95 | #define I2C_SLV4_ADDR 0x31 96 | #define I2C_SLV4_REG 0x32 97 | #define I2C_SLV4_DO 0x33 98 | #define I2C_SLV4_CTRL 0x34 99 | #define I2C_SLV4_DI 0x35 100 | #define I2C_MST_STATUS 0x36 101 | #define INT_PIN_CFG 0x37 102 | #define INT_ENABLE 0x38 103 | #define DMP_INT_STATUS 0x39 // Check DMP interrupt 104 | #define INT_STATUS 0x3A 105 | #define ACCEL_XOUT_H 0x3B 106 | #define ACCEL_XOUT_L 0x3C 107 | #define ACCEL_YOUT_H 0x3D 108 | #define ACCEL_YOUT_L 0x3E 109 | #define ACCEL_ZOUT_H 0x3F 110 | #define ACCEL_ZOUT_L 0x40 111 | #define TEMP_OUT_H 0x41 112 | #define TEMP_OUT_L 0x42 113 | #define GYRO_XOUT_H 0x43 114 | #define GYRO_XOUT_L 0x44 115 | #define GYRO_YOUT_H 0x45 116 | #define GYRO_YOUT_L 0x46 117 | #define GYRO_ZOUT_H 0x47 118 | #define GYRO_ZOUT_L 0x48 119 | #define EXT_SENS_DATA_00 0x49 120 | #define EXT_SENS_DATA_01 0x4A 121 | #define EXT_SENS_DATA_02 0x4B 122 | #define EXT_SENS_DATA_03 0x4C 123 | #define EXT_SENS_DATA_04 0x4D 124 | #define EXT_SENS_DATA_05 0x4E 125 | #define EXT_SENS_DATA_06 0x4F 126 | #define EXT_SENS_DATA_07 0x50 127 | #define EXT_SENS_DATA_08 0x51 128 | #define EXT_SENS_DATA_09 0x52 129 | #define EXT_SENS_DATA_10 0x53 130 | #define EXT_SENS_DATA_11 0x54 131 | #define EXT_SENS_DATA_12 0x55 132 | #define EXT_SENS_DATA_13 0x56 133 | #define EXT_SENS_DATA_14 0x57 134 | #define EXT_SENS_DATA_15 0x58 135 | #define EXT_SENS_DATA_16 0x59 136 | #define EXT_SENS_DATA_17 0x5A 137 | #define EXT_SENS_DATA_18 0x5B 138 | #define EXT_SENS_DATA_19 0x5C 139 | #define EXT_SENS_DATA_20 0x5D 140 | #define EXT_SENS_DATA_21 0x5E 141 | #define EXT_SENS_DATA_22 0x5F 142 | #define EXT_SENS_DATA_23 0x60 143 | #define MOT_DETECT_STATUS 0x61 144 | #define I2C_SLV0_DO 0x63 145 | #define I2C_SLV1_DO 0x64 146 | #define I2C_SLV2_DO 0x65 147 | #define I2C_SLV3_DO 0x66 148 | #define I2C_MST_DELAY_CTRL 0x67 149 | #define SIGNAL_PATH_RESET 0x68 150 | #define MOT_DETECT_CTRL 0x69 151 | #define USER_CTRL 0x6A // Bit 7 enable DMP, bit 3 reset DMP 152 | #define PWR_MGMT_1 0x6B // Device defaults to the SLEEP mode 153 | #define PWR_MGMT_2 0x6C 154 | #define DMP_BANK 0x6D // Activates a specific bank in the DMP 155 | #define DMP_RW_PNT 0x6E // Set read/write pointer to a specific start address in specified DMP bank 156 | #define DMP_REG 0x6F // Register in DMP from which to read or to which to write 157 | #define DMP_REG_1 0x70 158 | #define DMP_REG_2 0x71 159 | #define FIFO_COUNTH 0x72 160 | #define FIFO_COUNTL 0x73 161 | #define FIFO_R_W 0x74 162 | #define WHO_AM_I_MPU9250 0x75 // Should return 0x71 163 | #define XA_OFFSET_H 0x77 164 | #define XA_OFFSET_L 0x78 165 | #define YA_OFFSET_H 0x7A 166 | #define YA_OFFSET_L 0x7B 167 | #define ZA_OFFSET_H 0x7D 168 | #define ZA_OFFSET_L 0x7E 169 | 170 | // Using the MPU-9250 breakout board, ADO is set to 0 171 | // Seven-bit device address is 110100 for ADO = 0 and 110101 for ADO = 1 172 | #define ADO 0 173 | #if ADO 174 | #define MPU9250_ADDRESS 0x69 // Device address when ADO = 1 175 | #else 176 | #define MPU9250_ADDRESS 0x68 // Device address when ADO = 0 177 | #define AK8963_ADDRESS 0x0C // Address of magnetometer 178 | #endif // AD0 179 | 180 | class MPU9250 { 181 | protected: 182 | // Set initial input parameters 183 | enum Ascale { 184 | AFS_2G = 0, 185 | AFS_4G, 186 | AFS_8G, 187 | AFS_16G 188 | }; 189 | 190 | enum Gscale { 191 | GFS_250DPS = 0, 192 | GFS_500DPS, 193 | GFS_1000DPS, 194 | GFS_2000DPS 195 | }; 196 | 197 | enum Mscale { 198 | MFS_14BITS = 0, // 0.6 mG per LSB 199 | MFS_16BITS // 0.15 mG per LSB 200 | }; 201 | 202 | // Specify sensor full scale 203 | uint8_t Gscale = GFS_250DPS; 204 | uint8_t Ascale = AFS_2G; 205 | // Choose either 14-bit or 16-bit magnetometer resolution 206 | uint8_t Mscale = MFS_16BITS; 207 | // 2 for 8 Hz, 6 for 100 Hz continuous magnetometer data read 208 | uint8_t Mmode = 0x02; 209 | 210 | public: 211 | float pitch, yaw, roll; 212 | float temperature; // Stores the real internal chip temperature in Celsius 213 | int16_t tempCount; // Temperature raw count output 214 | uint32_t delt_t = 0; // Used to control display output rate 215 | 216 | uint32_t count = 0, sumCount = 0; // used to control display output rate 217 | float deltat = 0.0f, sum = 0.0f; // integration interval for both filter schemes 218 | uint32_t lastUpdate = 0, firstUpdate = 0; // used to calculate integration interval 219 | uint32_t Now = 0; // used to calculate integration interval 220 | 221 | int16_t gyroCount[3]; // Stores the 16-bit signed gyro sensor output 222 | int16_t magCount[3]; // Stores the 16-bit signed magnetometer sensor output 223 | // Scale resolutions per LSB for the sensors 224 | float aRes, gRes, mRes; 225 | // Variables to hold latest sensor data values 226 | float ax, ay, az, gx, gy, gz, mx, my, mz; 227 | // Factory mag calibration and mag bias 228 | float magCalibration[3] = {0, 0, 0}, magbias[3] = {0, 0, 0}; 229 | // Bias corrections for gyro and accelerometer 230 | float gyroBias[3] = {0, 0, 0}, accelBias[3] = {0, 0, 0}; 231 | float SelfTest[6]; 232 | // Stores the 16-bit signed accelerometer sensor output 233 | int16_t accelCount[3]; 234 | 235 | public: 236 | void getMres(); 237 | void getGres(); 238 | void getAres(); 239 | void readAccelData(int16_t *); 240 | void readGyroData(int16_t *); 241 | void readMagData(int16_t *); 242 | int16_t readTempData(); 243 | void updateTime(); 244 | void initAK8963(float *); 245 | void initMPU9250(); 246 | void calibrateMPU9250(float * gyroBias, float * accelBias); 247 | void MPU9250SelfTest(float * destination); 248 | void writeByte(uint8_t, uint8_t, uint8_t); 249 | uint8_t readByte(uint8_t, uint8_t); 250 | void readBytes(uint8_t, uint8_t, uint8_t, uint8_t *); 251 | }; // class MPU9250 252 | 253 | #endif // _MPU9250_H_ 254 | -------------------------------------------------------------------------------- /lib/src/utility/quaternionFilters.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Implementation of Sebastian Madgwick's "...efficient orientation filter 3 | // for... inertial/magnetic sensor arrays" 4 | // (see http://www.x-io.co.uk/category/open-source/ for examples & more details) 5 | // which fuses acceleration, rotation rate, and magnetic moments to produce a 6 | // quaternion-based estimate of absolute device orientation -- which can be 7 | // converted to yaw, pitch, and roll. Useful for stabilizing quadcopters, etc. 8 | // The performance of the orientation filter is at least as good as conventional 9 | // Kalman-based filtering algorithms but is much less computationally 10 | // intensive---it can be performed on a 3.3 V Pro Mini operating at 8 MHz! 11 | 12 | #include "quaternionFilters.h" 13 | 14 | // These are the free parameters in the Mahony filter and fusion scheme, Kp 15 | // for proportional feedback, Ki for integral 16 | #define Kp 2.0f * 5.0f 17 | #define Ki 0.0f 18 | 19 | static float GyroMeasError = PI * (40.0f / 180.0f); 20 | // gyroscope measurement drift in rad/s/s (start at 0.0 deg/s/s) 21 | // static float GyroMeasDrift = PI * (0.0f / 180.0f); 22 | // There is a tradeoff in the beta parameter between accuracy and response 23 | // speed. In the original Madgwick study, beta of 0.041 (corresponding to 24 | // GyroMeasError of 2.7 degrees/s) was found to give optimal accuracy. 25 | // However, with this value, the LSM9SD0 response time is about 10 seconds 26 | // to a stable initial quaternion. Subsequent changes also require a 27 | // longish lag time to a stable output, not fast enough for a quadcopter or 28 | // robot car! By increasing beta (GyroMeasError) by about a factor of 29 | // fifteen, the response time constant is reduced to ~2 sec. I haven't 30 | // noticed any reduction in solution accuracy. This is essentially the I 31 | // coefficient in a PID control sense; the bigger the feedback coefficient, 32 | // the faster the solution converges, usually at the expense of accuracy. 33 | // In any case, this is the free parameter in the Madgwick filtering and 34 | // fusion scheme. 35 | static float beta = sqrt(3.0f / 4.0f) * GyroMeasError; // Compute beta 36 | // Compute zeta, the other free parameter in the Madgwick scheme usually 37 | // set to a small or zero value 38 | // static float zeta = sqrt(3.0f / 4.0f) * GyroMeasDrift; 39 | 40 | // Vector to hold integral error for Mahony method 41 | static float eInt[3] = { 0.0f, 0.0f, 0.0f }; 42 | // Vector to hold quaternion 43 | static float q[4] = { 1.0f, 0.0f, 0.0f, 0.0f }; 44 | 45 | void MadgwickQuaternionUpdate(float ax, float ay, float az, float gx, float gy, float gz, float mx, float my, float mz, float deltat){ 46 | // short name local variable for readability 47 | float q1 = q[0], q2 = q[1], q3 = q[2], q4 = q[3]; 48 | float norm; 49 | float hx, hy, _2bx, _2bz; 50 | float s1, s2, s3, s4; 51 | float qDot1, qDot2, qDot3, qDot4; 52 | 53 | // Auxiliary variables to avoid repeated arithmetic 54 | float _2q1mx; 55 | float _2q1my; 56 | float _2q1mz; 57 | float _2q2mx; 58 | float _4bx; 59 | float _4bz; 60 | float _2q1 = 2.0f * q1; 61 | float _2q2 = 2.0f * q2; 62 | float _2q3 = 2.0f * q3; 63 | float _2q4 = 2.0f * q4; 64 | float _2q1q3 = 2.0f * q1 * q3; 65 | float _2q3q4 = 2.0f * q3 * q4; 66 | float q1q1 = q1 * q1; 67 | float q1q2 = q1 * q2; 68 | float q1q3 = q1 * q3; 69 | float q1q4 = q1 * q4; 70 | float q2q2 = q2 * q2; 71 | float q2q3 = q2 * q3; 72 | float q2q4 = q2 * q4; 73 | float q3q3 = q3 * q3; 74 | float q3q4 = q3 * q4; 75 | float q4q4 = q4 * q4; 76 | 77 | // Normalise accelerometer measurement 78 | norm = sqrt(ax * ax + ay * ay + az * az); 79 | if (norm == 0.0f) { 80 | return; // handle NaN 81 | } 82 | norm = 1.0f / norm; 83 | ax *= norm; 84 | ay *= norm; 85 | az *= norm; 86 | 87 | // Normalise magnetometer measurement 88 | norm = sqrt(mx * mx + my * my + mz * mz); 89 | if (norm == 0.0f) { 90 | return; // handle NaN 91 | } 92 | norm = 1.0f / norm; 93 | mx *= norm; 94 | my *= norm; 95 | mz *= norm; 96 | 97 | // Reference direction of Earth's magnetic field 98 | _2q1mx = 2.0f * q1 * mx; 99 | _2q1my = 2.0f * q1 * my; 100 | _2q1mz = 2.0f * q1 * mz; 101 | _2q2mx = 2.0f * q2 * mx; 102 | hx = mx * q1q1 - _2q1my * q4 + _2q1mz * q3 + mx * q2q2 + _2q2 * my * q3 + 103 | _2q2 * mz * q4 - mx * q3q3 - mx * q4q4; 104 | hy = _2q1mx * q4 + my * q1q1 - _2q1mz * q2 + _2q2mx * q3 - my * q2q2 + my * q3q3 + _2q3 * mz * q4 - my * q4q4; 105 | _2bx = sqrt(hx * hx + hy * hy); 106 | _2bz = -_2q1mx * q3 + _2q1my * q2 + mz * q1q1 + _2q2mx * q4 - mz * q2q2 + _2q3 * my * q4 - mz * q3q3 + mz * q4q4; 107 | _4bx = 2.0f * _2bx; 108 | _4bz = 2.0f * _2bz; 109 | 110 | // Gradient decent algorithm corrective step 111 | s1 = -_2q3 * (2.0f * q2q4 - _2q1q3 - ax) + _2q2 * (2.0f * q1q2 + _2q3q4 - ay) - _2bz * q3 * (_2bx * (0.5f - q3q3 - q4q4) + _2bz * (q2q4 - q1q3) - mx) + (-_2bx * q4 + _2bz * q2) * (_2bx * (q2q3 - q1q4) + _2bz * (q1q2 + q3q4) - my) + _2bx * q3 * (_2bx * (q1q3 + q2q4) + _2bz * (0.5f - q2q2 - q3q3) - mz); 112 | s2 = _2q4 * (2.0f * q2q4 - _2q1q3 - ax) + _2q1 * (2.0f * q1q2 + _2q3q4 - ay) - 4.0f * q2 * (1.0f - 2.0f * q2q2 - 2.0f * q3q3 - az) + _2bz * q4 * (_2bx * (0.5f - q3q3 - q4q4) + _2bz * (q2q4 - q1q3) - mx) + (_2bx * q3 + _2bz * q1) * (_2bx * (q2q3 - q1q4) + _2bz * (q1q2 + q3q4) - my) + (_2bx * q4 - _4bz * q2) * (_2bx * (q1q3 + q2q4) + _2bz * (0.5f - q2q2 - q3q3) - mz); 113 | s3 = -_2q1 * (2.0f * q2q4 - _2q1q3 - ax) + _2q4 * (2.0f * q1q2 + _2q3q4 - ay) - 4.0f * q3 * (1.0f - 2.0f * q2q2 - 2.0f * q3q3 - az) + (-_4bx * q3 - _2bz * q1) * (_2bx * (0.5f - q3q3 - q4q4) + _2bz * (q2q4 - q1q3) - mx) + (_2bx * q2 + _2bz * q4) * (_2bx * (q2q3 - q1q4) + _2bz * (q1q2 + q3q4) - my) + (_2bx * q1 - _4bz * q3) * (_2bx * (q1q3 + q2q4) + _2bz * (0.5f - q2q2 - q3q3) - mz); 114 | s4 = _2q2 * (2.0f * q2q4 - _2q1q3 - ax) + _2q3 * (2.0f * q1q2 + _2q3q4 - ay) + (-_4bx * q4 + _2bz * q2) * (_2bx * (0.5f - q3q3 - q4q4) + _2bz * (q2q4 - q1q3) - mx) + (-_2bx * q1 + _2bz * q3) * (_2bx * (q2q3 - q1q4) + _2bz * (q1q2 + q3q4) - my) + _2bx * q2 * (_2bx * (q1q3 + q2q4) + _2bz * (0.5f - q2q2 - q3q3) - mz); 115 | norm = sqrt(s1 * s1 + s2 * s2 + s3 * s3 + s4 * s4); // normalise step magnitude 116 | norm = 1.0f / norm; 117 | s1 *= norm; 118 | s2 *= norm; 119 | s3 *= norm; 120 | s4 *= norm; 121 | 122 | // Compute rate of change of quaternion 123 | qDot1 = 0.5f * (-q2 * gx - q3 * gy - q4 * gz) - beta * s1; 124 | qDot2 = 0.5f * (q1 * gx + q3 * gz - q4 * gy) - beta * s2; 125 | qDot3 = 0.5f * (q1 * gy - q2 * gz + q4 * gx) - beta * s3; 126 | qDot4 = 0.5f * (q1 * gz + q2 * gy - q3 * gx) - beta * s4; 127 | 128 | // Integrate to yield quaternion 129 | q1 += qDot1 * deltat; 130 | q2 += qDot2 * deltat; 131 | q3 += qDot3 * deltat; 132 | q4 += qDot4 * deltat; 133 | norm = sqrt(q1 * q1 + q2 * q2 + q3 * q3 + q4 * q4); // normalise quaternion 134 | norm = 1.0f / norm; 135 | q[0] = q1 * norm; 136 | q[1] = q2 * norm; 137 | q[2] = q3 * norm; 138 | q[3] = q4 * norm; 139 | } 140 | 141 | 142 | 143 | // Similar to Madgwick scheme but uses proportional and integral filtering on 144 | // the error between estimated reference vectors and measured ones. 145 | void MahonyQuaternionUpdate(float ax, float ay, float az, float gx, float gy, float gz, float mx, float my, float mz, float deltat){ 146 | // short name local variable for readability 147 | float q1 = q[0], q2 = q[1], q3 = q[2], q4 = q[3]; 148 | float norm; 149 | float hx, hy, bx, bz; 150 | float vx, vy, vz, wx, wy, wz; 151 | float ex, ey, ez; 152 | float pa, pb, pc; 153 | 154 | // Auxiliary variables to avoid repeated arithmetic 155 | float q1q1 = q1 * q1; 156 | float q1q2 = q1 * q2; 157 | float q1q3 = q1 * q3; 158 | float q1q4 = q1 * q4; 159 | float q2q2 = q2 * q2; 160 | float q2q3 = q2 * q3; 161 | float q2q4 = q2 * q4; 162 | float q3q3 = q3 * q3; 163 | float q3q4 = q3 * q4; 164 | float q4q4 = q4 * q4; 165 | 166 | // Normalise accelerometer measurement 167 | norm = sqrt(ax * ax + ay * ay + az * az); 168 | if (norm == 0.0f) { 169 | return; // Handle NaN 170 | } 171 | norm = 1.0f / norm; // Use reciprocal for division 172 | ax *= norm; 173 | ay *= norm; 174 | az *= norm; 175 | 176 | // Normalise magnetometer measurement 177 | norm = sqrt(mx * mx + my * my + mz * mz); 178 | if (norm == 0.0f) { 179 | return; // Handle NaN 180 | } 181 | norm = 1.0f / norm; // Use reciprocal for division 182 | mx *= norm; 183 | my *= norm; 184 | mz *= norm; 185 | 186 | // Reference direction of Earth's magnetic field 187 | hx = 2.0f * mx * (0.5f - q3q3 - q4q4) + 2.0f * my * (q2q3 - q1q4) + 2.0f * mz * (q2q4 + q1q3); 188 | hy = 2.0f * mx * (q2q3 + q1q4) + 2.0f * my * (0.5f - q2q2 - q4q4) + 2.0f * mz * (q3q4 - q1q2); 189 | bx = sqrt((hx * hx) + (hy * hy)); 190 | bz = 2.0f * mx * (q2q4 - q1q3) + 2.0f * my * (q3q4 + q1q2) + 2.0f * mz * (0.5f - q2q2 - q3q3); 191 | 192 | // Estimated direction of gravity and magnetic field 193 | vx = 2.0f * (q2q4 - q1q3); 194 | vy = 2.0f * (q1q2 + q3q4); 195 | vz = q1q1 - q2q2 - q3q3 + q4q4; 196 | wx = 2.0f * bx * (0.5f - q3q3 - q4q4) + 2.0f * bz * (q2q4 - q1q3); 197 | wy = 2.0f * bx * (q2q3 - q1q4) + 2.0f * bz * (q1q2 + q3q4); 198 | wz = 2.0f * bx * (q1q3 + q2q4) + 2.0f * bz * (0.5f - q2q2 - q3q3); 199 | 200 | // Error is cross product between estimated direction and measured direction of gravity 201 | ex = (ay * vz - az * vy) + (my * wz - mz * wy); 202 | ey = (az * vx - ax * vz) + (mz * wx - mx * wz); 203 | ez = (ax * vy - ay * vx) + (mx * wy - my * wx); 204 | if (Ki > 0.0f){ 205 | eInt[0] += ex; // accumulate integral error 206 | eInt[1] += ey; 207 | eInt[2] += ez; 208 | }else{ 209 | eInt[0] = 0.0f; // prevent integral wind up 210 | eInt[1] = 0.0f; 211 | eInt[2] = 0.0f; 212 | } 213 | 214 | // Apply feedback terms 215 | gx = gx + Kp * ex + Ki * eInt[0]; 216 | gy = gy + Kp * ey + Ki * eInt[1]; 217 | gz = gz + Kp * ez + Ki * eInt[2]; 218 | 219 | // Integrate rate of change of quaternion 220 | pa = q2; 221 | pb = q3; 222 | pc = q4; 223 | q1 = q1 + (-q2 * gx - q3 * gy - q4 * gz) * (0.5f * deltat); 224 | q2 = pa + (q1 * gx + pb * gz - pc * gy) * (0.5f * deltat); 225 | q3 = pb + (q1 * gy - pa * gz + pc * gx) * (0.5f * deltat); 226 | q4 = pc + (q1 * gz + pa * gy - pb * gx) * (0.5f * deltat); 227 | 228 | // Normalise quaternion 229 | norm = sqrt(q1 * q1 + q2 * q2 + q3 * q3 + q4 * q4); 230 | norm = 1.0f / norm; 231 | q[0] = q1 * norm; 232 | q[1] = q2 * norm; 233 | q[2] = q3 * norm; 234 | q[3] = q4 * norm; 235 | } 236 | 237 | const float * getQ () { 238 | return q; 239 | } 240 | -------------------------------------------------------------------------------- /lib/src/Free_Fonts.h: -------------------------------------------------------------------------------- 1 | // Attach this header file to your sketch to use the GFX Free Fonts. You can write 2 | // sketches without it, but it makes referencing them easier. 3 | 4 | // This calls up ALL the fonts but they only get loaded if you actually 5 | // use them in your sketch. 6 | // 7 | // No changes are needed to this header file unless new fonts are added to the 8 | // library "Fonts/GFXFF" folder. 9 | // 10 | // To save a lot of typing long names, each font can easily be referenced in the 11 | // sketch in three ways, either with: 12 | // 13 | // 1. Font file name with the & in front such as &FreeSansBoldOblique24pt7b 14 | // an example being: 15 | // 16 | // tft.setFreeFont(&FreeSansBoldOblique24pt7b); 17 | // 18 | // 2. FF# where # is a number determined by looking at the list below 19 | // an example being: 20 | // 21 | // tft.setFreeFont(FF32); 22 | // 23 | // 3. An abbreviation of the file name. Look at the list below to see 24 | // the abbreviations used, for example: 25 | // 26 | // tft.setFreeFont(FSSBO24) 27 | // 28 | // Where the letters mean: 29 | // F = Free font 30 | // M = Mono 31 | // SS = Sans Serif (double S to distinguish is form serif fonts) 32 | // S = Serif 33 | // B = Bold 34 | // O = Oblique (letter O not zero) 35 | // I = Italic 36 | // # = point size, either 9, 12, 18 or 24 37 | // 38 | // Setting the font to NULL will select the GLCD font: 39 | // 40 | // tft.setFreeFont(NULL); // Set font to GLCD 41 | 42 | #define LOAD_GFXFF 43 | 44 | #ifdef LOAD_GFXFF // Only include the fonts if LOAD_GFXFF is defined in User_Setup.h 45 | 46 | // Use these when printing or drawing text in GLCD and high rendering speed fonts 47 | #define GFXFF 1 48 | #define GLCD 0 49 | #define FONT2 2 50 | #define FONT4 4 51 | #define FONT6 6 52 | #define FONT7 7 53 | #define FONT8 8 54 | 55 | // Use the following when calling setFont() 56 | // 57 | // Reserved for GLCD font // FF0 58 | // 59 | 60 | #define TT1 &TomThumb 61 | 62 | #define FM9 &FreeMono9pt7b 63 | #define FM12 &FreeMono12pt7b 64 | #define FM18 &FreeMono18pt7b 65 | #define FM24 &FreeMono24pt7b 66 | 67 | #define FMB9 &FreeMonoBold9pt7b 68 | #define FMB12 &FreeMonoBold12pt7b 69 | #define FMB18 &FreeMonoBold18pt7b 70 | #define FMB24 &FreeMonoBold24pt7b 71 | 72 | #define FMO9 &FreeMonoOblique9pt7b 73 | #define FMO12 &FreeMonoOblique12pt7b 74 | #define FMO18 &FreeMonoOblique18pt7b 75 | #define FMO24 &FreeMonoOblique24pt7b 76 | 77 | #define FMBO9 &FreeMonoBoldOblique9pt7b 78 | #define FMBO12 &FreeMonoBoldOblique12pt7b 79 | #define FMBO18 &FreeMonoBoldOblique18pt7b 80 | #define FMBO24 &FreeMonoBoldOblique24pt7b 81 | 82 | #define FSS9 &FreeSans9pt7b 83 | #define FSS12 &FreeSans12pt7b 84 | #define FSS18 &FreeSans18pt7b 85 | #define FSS24 &FreeSans24pt7b 86 | 87 | #define FSSB9 &FreeSansBold9pt7b 88 | #define FSSB12 &FreeSansBold12pt7b 89 | #define FSSB18 &FreeSansBold18pt7b 90 | #define FSSB24 &FreeSansBold24pt7b 91 | 92 | #define FSSO9 &FreeSansOblique9pt7b 93 | #define FSSO12 &FreeSansOblique12pt7b 94 | #define FSSO18 &FreeSansOblique18pt7b 95 | #define FSSO24 &FreeSansOblique24pt7b 96 | 97 | #define FSSBO9 &FreeSansBoldOblique9pt7b 98 | #define FSSBO12 &FreeSansBoldOblique12pt7b 99 | #define FSSBO18 &FreeSansBoldOblique18pt7b 100 | #define FSSBO24 &FreeSansBoldOblique24pt7b 101 | 102 | #define FS9 &FreeSerif9pt7b 103 | #define FS12 &FreeSerif12pt7b 104 | #define FS18 &FreeSerif18pt7b 105 | #define FS24 &FreeSerif24pt7b 106 | 107 | #define FSI9 &FreeSerifItalic9pt7b 108 | #define FSI12 &FreeSerifItalic12pt7b 109 | #define FSI19 &FreeSerifItalic18pt7b 110 | #define FSI24 &FreeSerifItalic24pt7b 111 | 112 | #define FSB9 &FreeSerifBold9pt7b 113 | #define FSB12 &FreeSerifBold12pt7b 114 | #define FSB18 &FreeSerifBold18pt7b 115 | #define FSB24 &FreeSerifBold24pt7b 116 | 117 | #define FSBI9 &FreeSerifBoldItalic9pt7b 118 | #define FSBI12 &FreeSerifBoldItalic12pt7b 119 | #define FSBI18 &FreeSerifBoldItalic18pt7b 120 | #define FSBI24 &FreeSerifBoldItalic24pt7b 121 | 122 | #define FF0 NULL //ff0 reserved for GLCD 123 | #define FF1 &FreeMono9pt7b 124 | #define FF2 &FreeMono12pt7b 125 | #define FF3 &FreeMono18pt7b 126 | #define FF4 &FreeMono24pt7b 127 | 128 | #define FF5 &FreeMonoBold9pt7b 129 | #define FF6 &FreeMonoBold12pt7b 130 | #define FF7 &FreeMonoBold18pt7b 131 | #define FF8 &FreeMonoBold24pt7b 132 | 133 | #define FF9 &FreeMonoOblique9pt7b 134 | #define FF10 &FreeMonoOblique12pt7b 135 | #define FF11 &FreeMonoOblique18pt7b 136 | #define FF12 &FreeMonoOblique24pt7b 137 | 138 | #define FF13 &FreeMonoBoldOblique9pt7b 139 | #define FF14 &FreeMonoBoldOblique12pt7b 140 | #define FF15 &FreeMonoBoldOblique18pt7b 141 | #define FF16 &FreeMonoBoldOblique24pt7b 142 | 143 | #define FF17 &FreeSans9pt7b 144 | #define FF18 &FreeSans12pt7b 145 | #define FF19 &FreeSans18pt7b 146 | #define FF20 &FreeSans24pt7b 147 | 148 | #define FF21 &FreeSansBold9pt7b 149 | #define FF22 &FreeSansBold12pt7b 150 | #define FF23 &FreeSansBold18pt7b 151 | #define FF24 &FreeSansBold24pt7b 152 | 153 | #define FF25 &FreeSansOblique9pt7b 154 | #define FF26 &FreeSansOblique12pt7b 155 | #define FF27 &FreeSansOblique18pt7b 156 | #define FF28 &FreeSansOblique24pt7b 157 | 158 | #define FF29 &FreeSansBoldOblique9pt7b 159 | #define FF30 &FreeSansBoldOblique12pt7b 160 | #define FF31 &FreeSansBoldOblique18pt7b 161 | #define FF32 &FreeSansBoldOblique24pt7b 162 | 163 | #define FF33 &FreeSerif9pt7b 164 | #define FF34 &FreeSerif12pt7b 165 | #define FF35 &FreeSerif18pt7b 166 | #define FF36 &FreeSerif24pt7b 167 | 168 | #define FF37 &FreeSerifItalic9pt7b 169 | #define FF38 &FreeSerifItalic12pt7b 170 | #define FF39 &FreeSerifItalic18pt7b 171 | #define FF40 &FreeSerifItalic24pt7b 172 | 173 | #define FF41 &FreeSerifBold9pt7b 174 | #define FF42 &FreeSerifBold12pt7b 175 | #define FF43 &FreeSerifBold18pt7b 176 | #define FF44 &FreeSerifBold24pt7b 177 | 178 | #define FF45 &FreeSerifBoldItalic9pt7b 179 | #define FF46 &FreeSerifBoldItalic12pt7b 180 | #define FF47 &FreeSerifBoldItalic18pt7b 181 | #define FF48 &FreeSerifBoldItalic24pt7b 182 | 183 | // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 184 | // Now we define "s"tring versions for easy printing of the font name so: 185 | // tft.println(sFF5); 186 | // will print 187 | // Mono bold 9 188 | // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 189 | 190 | #define sFF0 "GLCD" 191 | #define sTT1 "Tom Thumb" 192 | #define sFF1 "Mono 9" 193 | #define sFF2 "Mono 12" 194 | #define sFF3 "Mono 18" 195 | #define sFF4 "Mono 24" 196 | 197 | #define sFF5 "Mono bold 9" 198 | #define sFF6 "Mono bold 12" 199 | #define sFF7 "Mono bold 18" 200 | #define sFF8 "Mono bold 24" 201 | 202 | #define sFF9 "Mono oblique 9" 203 | #define sFF10 "Mono oblique 12" 204 | #define sFF11 "Mono oblique 18" 205 | #define sFF12 "Mono oblique 24" 206 | 207 | #define sFF13 "Mono bold oblique 9" 208 | #define sFF14 "Mono bold oblique 12" 209 | #define sFF15 "Mono bold oblique 18" 210 | #define sFF16 "Mono bold oblique 24" // Full text line is too big for 480 pixel wide screen 211 | 212 | #define sFF17 "Sans 9" 213 | #define sFF18 "Sans 12" 214 | #define sFF19 "Sans 18" 215 | #define sFF20 "Sans 24" 216 | 217 | #define sFF21 "Sans bold 9" 218 | #define sFF22 "Sans bold 12" 219 | #define sFF23 "Sans bold 18" 220 | #define sFF24 "Sans bold 24" 221 | 222 | #define sFF25 "Sans oblique 9" 223 | #define sFF26 "Sans oblique 12" 224 | #define sFF27 "Sans oblique 18" 225 | #define sFF28 "Sans oblique 24" 226 | 227 | #define sFF29 "Sans bold oblique 9" 228 | #define sFF30 "Sans bold oblique 12" 229 | #define sFF31 "Sans bold oblique 18" 230 | #define sFF32 "Sans bold oblique 24" 231 | 232 | #define sFF33 "Serif 9" 233 | #define sFF34 "Serif 12" 234 | #define sFF35 "Serif 18" 235 | #define sFF36 "Serif 24" 236 | 237 | #define sFF37 "Serif italic 9" 238 | #define sFF38 "Serif italic 12" 239 | #define sFF39 "Serif italic 18" 240 | #define sFF40 "Serif italic 24" 241 | 242 | #define sFF41 "Serif bold 9" 243 | #define sFF42 "Serif bold 12" 244 | #define sFF43 "Serif bold 18" 245 | #define sFF44 "Serif bold 24" 246 | 247 | #define sFF45 "Serif bold italic 9" 248 | #define sFF46 "Serif bold italic 12" 249 | #define sFF47 "Serif bold italic 18" 250 | #define sFF48 "Serif bold italic 24" 251 | 252 | #else // LOAD_GFXFF not defined so setup defaults to prevent error messages 253 | 254 | // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 255 | // Free fonts are not loaded in User_Setup.h so we must define all as font 1 256 | // to prevent compile error messages 257 | // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 258 | 259 | #define GFXFF 1 260 | #define GLCD 1 261 | #define FONT2 2 262 | #define FONT4 4 263 | #define FONT6 6 264 | #define FONT7 7 265 | #define FONT8 8 266 | 267 | #define FF0 1 268 | #define FF1 1 269 | #define FF2 1 270 | #define FF3 1 271 | #define FF4 1 272 | #define FF5 1 273 | #define FF6 1 274 | #define FF7 1 275 | #define FF8 1 276 | #define FF9 1 277 | #define FF10 1 278 | #define FF11 1 279 | #define FF12 1 280 | #define FF13 1 281 | #define FF14 1 282 | #define FF15 1 283 | #define FF16 1 284 | #define FF17 1 285 | #define FF18 1 286 | #define FF19 1 287 | #define FF20 1 288 | #define FF21 1 289 | #define FF22 1 290 | #define FF23 1 291 | #define FF24 1 292 | #define FF25 1 293 | #define FF26 1 294 | #define FF27 1 295 | #define FF28 1 296 | #define FF29 1 297 | #define FF30 1 298 | #define FF31 1 299 | #define FF32 1 300 | #define FF33 1 301 | #define FF34 1 302 | #define FF35 1 303 | #define FF36 1 304 | #define FF37 1 305 | #define FF38 1 306 | #define FF39 1 307 | #define FF40 1 308 | #define FF41 1 309 | #define FF42 1 310 | #define FF43 1 311 | #define FF44 1 312 | #define FF45 1 313 | #define FF46 1 314 | #define FF47 1 315 | #define FF48 1 316 | 317 | #define FM9 1 318 | #define FM12 1 319 | #define FM18 1 320 | #define FM24 1 321 | 322 | #define FMB9 1 323 | #define FMB12 1 324 | #define FMB18 1 325 | #define FMB24 1 326 | 327 | #define FMO9 1 328 | #define FMO12 1 329 | #define FMO18 1 330 | #define FMO24 1 331 | 332 | #define FMBO9 1 333 | #define FMBO12 1 334 | #define FMBO18 1 335 | #define FMBO24 1 336 | 337 | #define FSS9 1 338 | #define FSS12 1 339 | #define FSS18 1 340 | #define FSS24 1 341 | 342 | #define FSSB9 1 343 | #define FSSB12 1 344 | #define FSSB18 1 345 | #define FSSB24 1 346 | 347 | #define FSSO9 1 348 | #define FSSO12 1 349 | #define FSSO18 1 350 | #define FSSO24 1 351 | 352 | #define FSSBO9 1 353 | #define FSSBO12 1 354 | #define FSSBO18 1 355 | #define FSSBO24 1 356 | 357 | #define FS9 1 358 | #define FS12 1 359 | #define FS18 1 360 | #define FS24 1 361 | 362 | #define FSI9 1 363 | #define FSI12 1 364 | #define FSI19 1 365 | #define FSI24 1 366 | 367 | #define FSB9 1 368 | #define FSB12 1 369 | #define FSB18 1 370 | #define FSB24 1 371 | 372 | #define FSBI9 1 373 | #define FSBI12 1 374 | #define FSBI18 1 375 | #define FSBI24 1 376 | 377 | #endif // LOAD_GFXFF 378 | -------------------------------------------------------------------------------- /lib/src/Fonts/GFXFF/FreeMono9pt7b.h: -------------------------------------------------------------------------------- 1 | const uint8_t FreeMono9pt7bBitmaps[] PROGMEM = { 2 | 0xAA, 0xA8, 0x0C, 0xED, 0x24, 0x92, 0x48, 0x24, 0x48, 0x91, 0x2F, 0xE4, 3 | 0x89, 0x7F, 0x28, 0x51, 0x22, 0x40, 0x08, 0x3E, 0x62, 0x40, 0x30, 0x0E, 4 | 0x01, 0x81, 0xC3, 0xBE, 0x08, 0x08, 0x71, 0x12, 0x23, 0x80, 0x23, 0xB8, 5 | 0x0E, 0x22, 0x44, 0x70, 0x38, 0x81, 0x02, 0x06, 0x1A, 0x65, 0x46, 0xC8, 6 | 0xEC, 0xE9, 0x24, 0x5A, 0xAA, 0xA9, 0x40, 0xA9, 0x55, 0x5A, 0x80, 0x10, 7 | 0x22, 0x4B, 0xE3, 0x05, 0x11, 0x00, 0x10, 0x20, 0x47, 0xF1, 0x02, 0x04, 8 | 0x00, 0x6B, 0x48, 0xFF, 0x00, 0xF0, 0x02, 0x08, 0x10, 0x60, 0x81, 0x04, 9 | 0x08, 0x20, 0x41, 0x02, 0x08, 0x00, 0x38, 0x8A, 0x0C, 0x18, 0x30, 0x60, 10 | 0xC1, 0x82, 0x88, 0xE0, 0x27, 0x28, 0x42, 0x10, 0x84, 0x21, 0x3E, 0x38, 11 | 0x8A, 0x08, 0x10, 0x20, 0x82, 0x08, 0x61, 0x03, 0xF8, 0x7C, 0x06, 0x02, 12 | 0x02, 0x1C, 0x06, 0x01, 0x01, 0x01, 0x42, 0x3C, 0x18, 0xA2, 0x92, 0x8A, 13 | 0x28, 0xBF, 0x08, 0x21, 0xC0, 0x7C, 0x81, 0x03, 0xE4, 0x40, 0x40, 0x81, 14 | 0x03, 0x88, 0xE0, 0x1E, 0x41, 0x04, 0x0B, 0x98, 0xB0, 0xC1, 0xC2, 0x88, 15 | 0xE0, 0xFE, 0x04, 0x08, 0x20, 0x40, 0x82, 0x04, 0x08, 0x20, 0x40, 0x38, 16 | 0x8A, 0x0C, 0x14, 0x47, 0x11, 0x41, 0x83, 0x8C, 0xE0, 0x38, 0x8A, 0x1C, 17 | 0x18, 0x68, 0xCE, 0x81, 0x04, 0x13, 0xC0, 0xF0, 0x0F, 0x6C, 0x00, 0xD2, 18 | 0xD2, 0x00, 0x03, 0x04, 0x18, 0x60, 0x60, 0x18, 0x04, 0x03, 0xFF, 0x80, 19 | 0x00, 0x1F, 0xF0, 0x40, 0x18, 0x03, 0x00, 0x60, 0x20, 0x60, 0xC0, 0x80, 20 | 0x3D, 0x84, 0x08, 0x30, 0xC2, 0x00, 0x00, 0x00, 0x30, 0x3C, 0x46, 0x82, 21 | 0x8E, 0xB2, 0xA2, 0xA2, 0x9F, 0x80, 0x80, 0x40, 0x3C, 0x3C, 0x01, 0x40, 22 | 0x28, 0x09, 0x01, 0x10, 0x42, 0x0F, 0xC1, 0x04, 0x40, 0x9E, 0x3C, 0xFE, 23 | 0x21, 0x90, 0x48, 0x67, 0xE2, 0x09, 0x02, 0x81, 0x41, 0xFF, 0x80, 0x3E, 24 | 0xB0, 0xF0, 0x30, 0x08, 0x04, 0x02, 0x00, 0x80, 0x60, 0x8F, 0x80, 0xFE, 25 | 0x21, 0x90, 0x68, 0x14, 0x0A, 0x05, 0x02, 0x83, 0x43, 0x7F, 0x00, 0xFF, 26 | 0x20, 0x90, 0x08, 0x87, 0xC2, 0x21, 0x00, 0x81, 0x40, 0xFF, 0xC0, 0xFF, 27 | 0xA0, 0x50, 0x08, 0x87, 0xC2, 0x21, 0x00, 0x80, 0x40, 0x78, 0x00, 0x1E, 28 | 0x98, 0x6C, 0x0A, 0x00, 0x80, 0x20, 0xF8, 0x0B, 0x02, 0x60, 0x87, 0xC0, 29 | 0xE3, 0xA0, 0x90, 0x48, 0x27, 0xF2, 0x09, 0x04, 0x82, 0x41, 0x71, 0xC0, 30 | 0xF9, 0x08, 0x42, 0x10, 0x84, 0x27, 0xC0, 0x1F, 0x02, 0x02, 0x02, 0x02, 31 | 0x02, 0x82, 0x82, 0xC6, 0x78, 0xE3, 0xA1, 0x11, 0x09, 0x05, 0x83, 0x21, 32 | 0x08, 0x84, 0x41, 0x70, 0xC0, 0xE0, 0x40, 0x40, 0x40, 0x40, 0x40, 0x41, 33 | 0x41, 0x41, 0xFF, 0xE0, 0xEC, 0x19, 0x45, 0x28, 0xA4, 0xA4, 0x94, 0x91, 34 | 0x12, 0x02, 0x40, 0x5C, 0x1C, 0xC3, 0xB0, 0x94, 0x4A, 0x24, 0x92, 0x49, 35 | 0x14, 0x8A, 0x43, 0x70, 0x80, 0x1E, 0x31, 0x90, 0x50, 0x18, 0x0C, 0x06, 36 | 0x02, 0x82, 0x63, 0x0F, 0x00, 0xFE, 0x43, 0x41, 0x41, 0x42, 0x7C, 0x40, 37 | 0x40, 0x40, 0xF0, 0x1C, 0x31, 0x90, 0x50, 0x18, 0x0C, 0x06, 0x02, 0x82, 38 | 0x63, 0x1F, 0x04, 0x07, 0x92, 0x30, 0xFE, 0x21, 0x90, 0x48, 0x24, 0x23, 39 | 0xE1, 0x10, 0x84, 0x41, 0x70, 0xC0, 0x3A, 0xCD, 0x0A, 0x03, 0x01, 0x80, 40 | 0xC1, 0xC7, 0x78, 0xFF, 0xC4, 0x62, 0x21, 0x00, 0x80, 0x40, 0x20, 0x10, 41 | 0x08, 0x1F, 0x00, 0xE3, 0xA0, 0x90, 0x48, 0x24, 0x12, 0x09, 0x04, 0x82, 42 | 0x22, 0x0E, 0x00, 0xF1, 0xE8, 0x10, 0x82, 0x10, 0x42, 0x10, 0x22, 0x04, 43 | 0x80, 0x50, 0x0C, 0x00, 0x80, 0xF1, 0xE8, 0x09, 0x11, 0x25, 0x44, 0xA8, 44 | 0x55, 0x0C, 0xA1, 0x8C, 0x31, 0x84, 0x30, 0xE3, 0xA0, 0x88, 0x82, 0x80, 45 | 0x80, 0xC0, 0x90, 0x44, 0x41, 0x71, 0xC0, 0xE3, 0xA0, 0x88, 0x82, 0x81, 46 | 0x40, 0x40, 0x20, 0x10, 0x08, 0x1F, 0x00, 0xFD, 0x0A, 0x20, 0x81, 0x04, 47 | 0x10, 0x21, 0x83, 0xFC, 0xEA, 0xAA, 0xAA, 0xC0, 0x80, 0x81, 0x03, 0x02, 48 | 0x04, 0x04, 0x08, 0x08, 0x10, 0x10, 0x20, 0x20, 0xD5, 0x55, 0x55, 0xC0, 49 | 0x10, 0x51, 0x22, 0x28, 0x20, 0xFF, 0xE0, 0x88, 0x80, 0x7E, 0x00, 0x80, 50 | 0x47, 0xEC, 0x14, 0x0A, 0x0C, 0xFB, 0xC0, 0x20, 0x10, 0x0B, 0xC6, 0x12, 51 | 0x05, 0x02, 0x81, 0x40, 0xB0, 0xB7, 0x80, 0x3A, 0x8E, 0x0C, 0x08, 0x10, 52 | 0x10, 0x9E, 0x03, 0x00, 0x80, 0x47, 0xA4, 0x34, 0x0A, 0x05, 0x02, 0x81, 53 | 0x21, 0x8F, 0x60, 0x3C, 0x43, 0x81, 0xFF, 0x80, 0x80, 0x61, 0x3E, 0x3D, 54 | 0x04, 0x3E, 0x41, 0x04, 0x10, 0x41, 0x0F, 0x80, 0x3D, 0xA1, 0xA0, 0x50, 55 | 0x28, 0x14, 0x09, 0x0C, 0x7A, 0x01, 0x01, 0x87, 0x80, 0xC0, 0x20, 0x10, 56 | 0x0B, 0xC6, 0x32, 0x09, 0x04, 0x82, 0x41, 0x20, 0xB8, 0xE0, 0x10, 0x01, 57 | 0xC0, 0x81, 0x02, 0x04, 0x08, 0x11, 0xFC, 0x10, 0x3E, 0x10, 0x84, 0x21, 58 | 0x08, 0x42, 0x3F, 0x00, 0xC0, 0x40, 0x40, 0x4F, 0x44, 0x58, 0x70, 0x48, 59 | 0x44, 0x42, 0xC7, 0x70, 0x20, 0x40, 0x81, 0x02, 0x04, 0x08, 0x10, 0x23, 60 | 0xF8, 0xB7, 0x64, 0x62, 0x31, 0x18, 0x8C, 0x46, 0x23, 0x91, 0x5E, 0x31, 61 | 0x90, 0x48, 0x24, 0x12, 0x09, 0x05, 0xC7, 0x3E, 0x31, 0xA0, 0x30, 0x18, 62 | 0x0C, 0x05, 0x8C, 0x7C, 0xDE, 0x30, 0x90, 0x28, 0x14, 0x0A, 0x05, 0x84, 63 | 0xBC, 0x40, 0x20, 0x38, 0x00, 0x3D, 0xA1, 0xA0, 0x50, 0x28, 0x14, 0x09, 64 | 0x0C, 0x7A, 0x01, 0x00, 0x80, 0xE0, 0xCE, 0xA1, 0x82, 0x04, 0x08, 0x10, 65 | 0x7C, 0x3A, 0x8D, 0x0B, 0x80, 0xF0, 0x70, 0xDE, 0x40, 0x40, 0xFC, 0x40, 66 | 0x40, 0x40, 0x40, 0x40, 0x41, 0x3E, 0xC3, 0x41, 0x41, 0x41, 0x41, 0x41, 67 | 0x43, 0x3D, 0xE3, 0xA0, 0x90, 0x84, 0x42, 0x20, 0xA0, 0x50, 0x10, 0xE3, 68 | 0xC0, 0x92, 0x4B, 0x25, 0x92, 0xA9, 0x98, 0x44, 0xE3, 0x31, 0x05, 0x01, 69 | 0x01, 0x41, 0x11, 0x05, 0xC7, 0xE3, 0xA0, 0x90, 0x84, 0x42, 0x40, 0xA0, 70 | 0x60, 0x10, 0x10, 0x08, 0x3E, 0x00, 0xFD, 0x08, 0x20, 0x82, 0x08, 0x10, 71 | 0xBF, 0x29, 0x24, 0xA2, 0x49, 0x26, 0xFF, 0xF8, 0x89, 0x24, 0x8A, 0x49, 72 | 0x2C, 0x61, 0x24, 0x30 }; 73 | 74 | const GFXglyph FreeMono9pt7bGlyphs[] PROGMEM = { 75 | { 0, 0, 0, 11, 0, 1 }, // 0x20 ' ' 76 | { 0, 2, 11, 11, 4, -10 }, // 0x21 '!' 77 | { 3, 6, 5, 11, 2, -10 }, // 0x22 '"' 78 | { 7, 7, 12, 11, 2, -10 }, // 0x23 '#' 79 | { 18, 8, 12, 11, 1, -10 }, // 0x24 '$' 80 | { 30, 7, 11, 11, 2, -10 }, // 0x25 '%' 81 | { 40, 7, 10, 11, 2, -9 }, // 0x26 '&' 82 | { 49, 3, 5, 11, 4, -10 }, // 0x27 ''' 83 | { 51, 2, 13, 11, 5, -10 }, // 0x28 '(' 84 | { 55, 2, 13, 11, 4, -10 }, // 0x29 ')' 85 | { 59, 7, 7, 11, 2, -10 }, // 0x2A '*' 86 | { 66, 7, 7, 11, 2, -8 }, // 0x2B '+' 87 | { 73, 3, 5, 11, 2, -1 }, // 0x2C ',' 88 | { 75, 9, 1, 11, 1, -5 }, // 0x2D '-' 89 | { 77, 2, 2, 11, 4, -1 }, // 0x2E '.' 90 | { 78, 7, 13, 11, 2, -11 }, // 0x2F '/' 91 | { 90, 7, 11, 11, 2, -10 }, // 0x30 '0' 92 | { 100, 5, 11, 11, 3, -10 }, // 0x31 '1' 93 | { 107, 7, 11, 11, 2, -10 }, // 0x32 '2' 94 | { 117, 8, 11, 11, 1, -10 }, // 0x33 '3' 95 | { 128, 6, 11, 11, 3, -10 }, // 0x34 '4' 96 | { 137, 7, 11, 11, 2, -10 }, // 0x35 '5' 97 | { 147, 7, 11, 11, 2, -10 }, // 0x36 '6' 98 | { 157, 7, 11, 11, 2, -10 }, // 0x37 '7' 99 | { 167, 7, 11, 11, 2, -10 }, // 0x38 '8' 100 | { 177, 7, 11, 11, 2, -10 }, // 0x39 '9' 101 | { 187, 2, 8, 11, 4, -7 }, // 0x3A ':' 102 | { 189, 3, 11, 11, 3, -7 }, // 0x3B ';' 103 | { 194, 8, 8, 11, 1, -8 }, // 0x3C '<' 104 | { 202, 9, 4, 11, 1, -6 }, // 0x3D '=' 105 | { 207, 9, 8, 11, 1, -8 }, // 0x3E '>' 106 | { 216, 7, 10, 11, 2, -9 }, // 0x3F '?' 107 | { 225, 8, 12, 11, 2, -10 }, // 0x40 '@' 108 | { 237, 11, 10, 11, 0, -9 }, // 0x41 'A' 109 | { 251, 9, 10, 11, 1, -9 }, // 0x42 'B' 110 | { 263, 9, 10, 11, 1, -9 }, // 0x43 'C' 111 | { 275, 9, 10, 11, 1, -9 }, // 0x44 'D' 112 | { 287, 9, 10, 11, 1, -9 }, // 0x45 'E' 113 | { 299, 9, 10, 11, 1, -9 }, // 0x46 'F' 114 | { 311, 10, 10, 11, 1, -9 }, // 0x47 'G' 115 | { 324, 9, 10, 11, 1, -9 }, // 0x48 'H' 116 | { 336, 5, 10, 11, 3, -9 }, // 0x49 'I' 117 | { 343, 8, 10, 11, 2, -9 }, // 0x4A 'J' 118 | { 353, 9, 10, 11, 1, -9 }, // 0x4B 'K' 119 | { 365, 8, 10, 11, 2, -9 }, // 0x4C 'L' 120 | { 375, 11, 10, 11, 0, -9 }, // 0x4D 'M' 121 | { 389, 9, 10, 11, 1, -9 }, // 0x4E 'N' 122 | { 401, 9, 10, 11, 1, -9 }, // 0x4F 'O' 123 | { 413, 8, 10, 11, 1, -9 }, // 0x50 'P' 124 | { 423, 9, 13, 11, 1, -9 }, // 0x51 'Q' 125 | { 438, 9, 10, 11, 1, -9 }, // 0x52 'R' 126 | { 450, 7, 10, 11, 2, -9 }, // 0x53 'S' 127 | { 459, 9, 10, 11, 1, -9 }, // 0x54 'T' 128 | { 471, 9, 10, 11, 1, -9 }, // 0x55 'U' 129 | { 483, 11, 10, 11, 0, -9 }, // 0x56 'V' 130 | { 497, 11, 10, 11, 0, -9 }, // 0x57 'W' 131 | { 511, 9, 10, 11, 1, -9 }, // 0x58 'X' 132 | { 523, 9, 10, 11, 1, -9 }, // 0x59 'Y' 133 | { 535, 7, 10, 11, 2, -9 }, // 0x5A 'Z' 134 | { 544, 2, 13, 11, 5, -10 }, // 0x5B '[' 135 | { 548, 7, 13, 11, 2, -11 }, // 0x5C '\' 136 | { 560, 2, 13, 11, 4, -10 }, // 0x5D ']' 137 | { 564, 7, 5, 11, 2, -10 }, // 0x5E '^' 138 | { 569, 11, 1, 11, 0, 2 }, // 0x5F '_' 139 | { 571, 3, 3, 11, 3, -11 }, // 0x60 '`' 140 | { 573, 9, 8, 11, 1, -7 }, // 0x61 'a' 141 | { 582, 9, 11, 11, 1, -10 }, // 0x62 'b' 142 | { 595, 7, 8, 11, 2, -7 }, // 0x63 'c' 143 | { 602, 9, 11, 11, 1, -10 }, // 0x64 'd' 144 | { 615, 8, 8, 11, 1, -7 }, // 0x65 'e' 145 | { 623, 6, 11, 11, 3, -10 }, // 0x66 'f' 146 | { 632, 9, 11, 11, 1, -7 }, // 0x67 'g' 147 | { 645, 9, 11, 11, 1, -10 }, // 0x68 'h' 148 | { 658, 7, 10, 11, 2, -9 }, // 0x69 'i' 149 | { 667, 5, 13, 11, 3, -9 }, // 0x6A 'j' 150 | { 676, 8, 11, 11, 2, -10 }, // 0x6B 'k' 151 | { 687, 7, 11, 11, 2, -10 }, // 0x6C 'l' 152 | { 697, 9, 8, 11, 1, -7 }, // 0x6D 'm' 153 | { 706, 9, 8, 11, 1, -7 }, // 0x6E 'n' 154 | { 715, 9, 8, 11, 1, -7 }, // 0x6F 'o' 155 | { 724, 9, 11, 11, 1, -7 }, // 0x70 'p' 156 | { 737, 9, 11, 11, 1, -7 }, // 0x71 'q' 157 | { 750, 7, 8, 11, 3, -7 }, // 0x72 'r' 158 | { 757, 7, 8, 11, 2, -7 }, // 0x73 's' 159 | { 764, 8, 10, 11, 2, -9 }, // 0x74 't' 160 | { 774, 8, 8, 11, 1, -7 }, // 0x75 'u' 161 | { 782, 9, 8, 11, 1, -7 }, // 0x76 'v' 162 | { 791, 9, 8, 11, 1, -7 }, // 0x77 'w' 163 | { 800, 9, 8, 11, 1, -7 }, // 0x78 'x' 164 | { 809, 9, 11, 11, 1, -7 }, // 0x79 'y' 165 | { 822, 7, 8, 11, 2, -7 }, // 0x7A 'z' 166 | { 829, 3, 13, 11, 4, -10 }, // 0x7B '{' 167 | { 834, 1, 13, 11, 5, -10 }, // 0x7C '|' 168 | { 836, 3, 13, 11, 4, -10 }, // 0x7D '}' 169 | { 841, 7, 3, 11, 2, -6 } }; // 0x7E '~' 170 | 171 | const GFXfont FreeMono9pt7b PROGMEM = { 172 | (uint8_t *)FreeMono9pt7bBitmaps, 173 | (GFXglyph *)FreeMono9pt7bGlyphs, 174 | 0x20, 0x7E, 18 }; 175 | 176 | // Approx. 1516 bytes 177 | -------------------------------------------------------------------------------- /lib/src/Fonts/GFXFF/FreeMonoOblique9pt7b.h: -------------------------------------------------------------------------------- 1 | const uint8_t FreeMonoOblique9pt7bBitmaps[] PROGMEM = { 2 | 0x11, 0x22, 0x24, 0x40, 0x00, 0xC0, 0xDE, 0xE5, 0x29, 0x00, 0x09, 0x05, 3 | 0x02, 0x82, 0x47, 0xF8, 0xA0, 0x51, 0xFE, 0x28, 0x14, 0x0A, 0x09, 0x00, 4 | 0x08, 0x1D, 0x23, 0x40, 0x70, 0x1C, 0x02, 0x82, 0x84, 0x78, 0x20, 0x20, 5 | 0x1C, 0x11, 0x08, 0x83, 0x80, 0x18, 0x71, 0xC0, 0x1C, 0x11, 0x08, 0x83, 6 | 0x80, 0x1E, 0x60, 0x81, 0x03, 0x0A, 0x65, 0x46, 0x88, 0xE8, 0xFA, 0x80, 7 | 0x12, 0x24, 0x48, 0x88, 0x88, 0x88, 0x80, 0x01, 0x11, 0x11, 0x11, 0x22, 8 | 0x44, 0x80, 0x10, 0x22, 0x5B, 0xC3, 0x0A, 0x22, 0x00, 0x04, 0x02, 0x02, 9 | 0x1F, 0xF0, 0x80, 0x40, 0x20, 0x00, 0x36, 0x4C, 0x80, 0xFF, 0x80, 0xF0, 10 | 0x00, 0x80, 0x80, 0x40, 0x40, 0x40, 0x20, 0x20, 0x20, 0x10, 0x10, 0x10, 11 | 0x08, 0x08, 0x00, 0x1C, 0x45, 0x0A, 0x18, 0x30, 0x61, 0x42, 0x85, 0x11, 12 | 0xC0, 0x04, 0x38, 0x90, 0x20, 0x81, 0x02, 0x04, 0x08, 0x23, 0xF8, 0x07, 13 | 0x04, 0xC4, 0x20, 0x10, 0x10, 0x30, 0x20, 0x20, 0x60, 0x40, 0x3F, 0x80, 14 | 0x0F, 0x00, 0x40, 0x20, 0x20, 0x60, 0x18, 0x04, 0x02, 0x01, 0x43, 0x1E, 15 | 0x00, 0x03, 0x05, 0x0A, 0x12, 0x22, 0x22, 0x42, 0x7F, 0x04, 0x04, 0x1E, 16 | 0x1F, 0x88, 0x08, 0x05, 0xC3, 0x30, 0x08, 0x04, 0x02, 0x02, 0x42, 0x1E, 17 | 0x00, 0x07, 0x18, 0x20, 0x40, 0x5C, 0xA6, 0xC2, 0x82, 0x82, 0xC4, 0x78, 18 | 0xFF, 0x04, 0x10, 0x20, 0x82, 0x04, 0x10, 0x20, 0x81, 0x00, 0x1E, 0x23, 19 | 0x41, 0x41, 0x62, 0x1C, 0x66, 0x82, 0x82, 0x84, 0x78, 0x1E, 0x23, 0x41, 20 | 0x41, 0x43, 0x65, 0x3A, 0x02, 0x04, 0x18, 0xE0, 0x6C, 0x00, 0x36, 0x18, 21 | 0xC0, 0x00, 0x19, 0x8C, 0xC4, 0x00, 0x01, 0x83, 0x06, 0x0C, 0x06, 0x00, 22 | 0x80, 0x30, 0x04, 0xFF, 0x80, 0x00, 0x1F, 0xF0, 0x20, 0x0C, 0x01, 0x00, 23 | 0x60, 0x20, 0x60, 0xC1, 0x80, 0x3D, 0x8E, 0x08, 0x10, 0xC6, 0x08, 0x00, 24 | 0x01, 0x80, 0x1C, 0x45, 0x0A, 0x79, 0x34, 0x69, 0x4E, 0x81, 0x03, 0x03, 25 | 0xC0, 0x0F, 0x00, 0x60, 0x12, 0x02, 0x40, 0x88, 0x21, 0x07, 0xE1, 0x04, 26 | 0x20, 0x5E, 0x3C, 0x3F, 0x84, 0x11, 0x04, 0x82, 0x3F, 0x88, 0x32, 0x04, 27 | 0x81, 0x60, 0xBF, 0xC0, 0x1E, 0x98, 0xD0, 0x28, 0x08, 0x04, 0x02, 0x01, 28 | 0x00, 0x41, 0x1F, 0x00, 0x3F, 0x0C, 0x22, 0x04, 0x81, 0x20, 0x48, 0x12, 29 | 0x09, 0x02, 0x43, 0x3F, 0x00, 0x3F, 0xC4, 0x11, 0x00, 0x88, 0x3E, 0x08, 30 | 0x82, 0x00, 0x82, 0x60, 0xBF, 0xE0, 0x3F, 0xE2, 0x08, 0x40, 0x11, 0x03, 31 | 0xE0, 0x44, 0x08, 0x01, 0x00, 0x60, 0x1F, 0x00, 0x1E, 0x98, 0xD0, 0x08, 32 | 0x08, 0x04, 0x7A, 0x05, 0x02, 0x41, 0x1F, 0x00, 0x3D, 0xE2, 0x18, 0x42, 33 | 0x08, 0x43, 0xF8, 0x41, 0x08, 0x21, 0x08, 0x21, 0x1E, 0xF0, 0x3F, 0x82, 34 | 0x02, 0x01, 0x00, 0x80, 0x40, 0x20, 0x20, 0x10, 0x7F, 0x00, 0x0F, 0xE0, 35 | 0x20, 0x04, 0x00, 0x80, 0x10, 0x02, 0x20, 0x84, 0x10, 0x84, 0x0F, 0x00, 36 | 0x3C, 0xE2, 0x10, 0x44, 0x11, 0x02, 0xC0, 0x64, 0x08, 0x81, 0x08, 0x61, 37 | 0x1E, 0x38, 0x3E, 0x02, 0x00, 0x80, 0x20, 0x10, 0x04, 0x01, 0x04, 0x42, 38 | 0x10, 0xBF, 0xE0, 0x38, 0x38, 0xC3, 0x05, 0x28, 0x29, 0x42, 0x52, 0x13, 39 | 0x10, 0x99, 0x84, 0x08, 0x20, 0x47, 0x8F, 0x00, 0x70, 0xE6, 0x08, 0xA1, 40 | 0x14, 0x22, 0x48, 0x49, 0x11, 0x22, 0x14, 0x43, 0x1E, 0x20, 0x1E, 0x18, 41 | 0x90, 0x28, 0x18, 0x0C, 0x06, 0x05, 0x02, 0x46, 0x1E, 0x00, 0x3F, 0x84, 42 | 0x31, 0x04, 0x81, 0x20, 0x8F, 0xC2, 0x00, 0x80, 0x60, 0x3E, 0x00, 0x1E, 43 | 0x18, 0x90, 0x28, 0x18, 0x0C, 0x06, 0x05, 0x02, 0x46, 0x1E, 0x08, 0x0F, 44 | 0x44, 0x60, 0x3F, 0x84, 0x31, 0x04, 0x81, 0x20, 0x8F, 0xC2, 0x10, 0x84, 45 | 0x60, 0xBC, 0x10, 0x0F, 0x88, 0xC8, 0x24, 0x01, 0x80, 0x38, 0x05, 0x02, 46 | 0xC2, 0x5E, 0x00, 0xFF, 0xC4, 0x44, 0x02, 0x01, 0x00, 0x80, 0x40, 0x60, 47 | 0x20, 0x7E, 0x00, 0xF1, 0xD0, 0x24, 0x09, 0x02, 0x41, 0xA0, 0x48, 0x12, 48 | 0x04, 0xC6, 0x1F, 0x00, 0xF1, 0xE8, 0x11, 0x02, 0x20, 0x82, 0x20, 0x44, 49 | 0x09, 0x01, 0x40, 0x28, 0x02, 0x00, 0xF1, 0xE8, 0x09, 0x12, 0x26, 0x45, 50 | 0x48, 0xAA, 0x29, 0x45, 0x28, 0xC6, 0x18, 0xC0, 0x38, 0xE2, 0x08, 0x26, 51 | 0x05, 0x00, 0x40, 0x18, 0x04, 0x81, 0x08, 0x41, 0x1C, 0x70, 0xE3, 0xA0, 52 | 0x90, 0x84, 0x81, 0x80, 0x80, 0x40, 0x20, 0x20, 0x7E, 0x00, 0x3F, 0x90, 53 | 0x88, 0x80, 0x80, 0x80, 0x80, 0x80, 0x82, 0x82, 0x7F, 0x00, 0x39, 0x08, 54 | 0x44, 0x21, 0x08, 0x42, 0x21, 0x0E, 0x00, 0x88, 0x44, 0x44, 0x22, 0x22, 55 | 0x11, 0x11, 0x38, 0x42, 0x11, 0x08, 0x42, 0x10, 0x84, 0x2E, 0x00, 0x08, 56 | 0x28, 0x92, 0x18, 0x20, 0xFF, 0xC0, 0xA4, 0x3E, 0x00, 0x80, 0x47, 0xA4, 57 | 0x34, 0x12, 0x18, 0xF7, 0x38, 0x01, 0x00, 0x40, 0x09, 0xE1, 0xC6, 0x20, 58 | 0x44, 0x09, 0x01, 0x30, 0x46, 0x13, 0xBC, 0x00, 0x1F, 0x48, 0x74, 0x0A, 59 | 0x00, 0x80, 0x20, 0x0C, 0x18, 0xF8, 0x01, 0x80, 0x40, 0x23, 0x96, 0x32, 60 | 0x0A, 0x05, 0x02, 0x81, 0x61, 0x1F, 0xE0, 0x1F, 0x30, 0xD0, 0x3F, 0xF8, 61 | 0x04, 0x01, 0x00, 0x7C, 0x07, 0xC3, 0x00, 0x80, 0xFE, 0x10, 0x04, 0x01, 62 | 0x00, 0x40, 0x10, 0x08, 0x0F, 0xE0, 0x1D, 0xD8, 0xC4, 0x12, 0x04, 0x82, 63 | 0x20, 0x8C, 0x61, 0xE8, 0x02, 0x01, 0x07, 0x80, 0x30, 0x04, 0x01, 0x00, 64 | 0x5C, 0x38, 0x88, 0x22, 0x08, 0x82, 0x21, 0x18, 0x4F, 0x3C, 0x04, 0x04, 65 | 0x00, 0x38, 0x08, 0x08, 0x08, 0x08, 0x10, 0x10, 0xFF, 0x01, 0x00, 0x80, 66 | 0x03, 0xF0, 0x10, 0x08, 0x04, 0x02, 0x02, 0x01, 0x00, 0x80, 0x40, 0x47, 67 | 0xC0, 0x38, 0x08, 0x04, 0x02, 0x71, 0x20, 0xA0, 0xA0, 0x68, 0x24, 0x11, 68 | 0x38, 0xE0, 0x3C, 0x04, 0x04, 0x08, 0x08, 0x08, 0x08, 0x08, 0x10, 0x10, 69 | 0xFF, 0x3E, 0xE2, 0x64, 0x88, 0x91, 0x12, 0x24, 0x48, 0x91, 0x17, 0x33, 70 | 0x37, 0x14, 0x4C, 0x24, 0x12, 0x09, 0x08, 0x85, 0xE3, 0x1E, 0x10, 0x90, 71 | 0x30, 0x18, 0x0C, 0x0B, 0x08, 0x78, 0x33, 0xC3, 0x8C, 0x40, 0x88, 0x12, 72 | 0x02, 0x60, 0x8C, 0x31, 0x78, 0x20, 0x08, 0x03, 0xE0, 0x00, 0x1C, 0xD8, 73 | 0xC4, 0x12, 0x04, 0x81, 0x20, 0x4C, 0x21, 0xF8, 0x02, 0x00, 0x81, 0xF0, 74 | 0x73, 0x8E, 0x04, 0x04, 0x02, 0x01, 0x00, 0x81, 0xFC, 0x1F, 0x61, 0x40, 75 | 0x3C, 0x03, 0x81, 0x82, 0xFC, 0x10, 0x63, 0xF9, 0x02, 0x04, 0x10, 0x20, 76 | 0x40, 0x7C, 0xE3, 0x10, 0x90, 0x48, 0x24, 0x22, 0x11, 0x18, 0xF6, 0xF3, 77 | 0xD0, 0x44, 0x10, 0x88, 0x24, 0x09, 0x02, 0x80, 0x40, 0xE1, 0xD0, 0x24, 78 | 0x91, 0x24, 0x55, 0x19, 0x86, 0x61, 0x10, 0x39, 0xC4, 0x20, 0xB0, 0x30, 79 | 0x0C, 0x04, 0x86, 0x13, 0x8E, 0x3C, 0x71, 0x04, 0x10, 0x40, 0x88, 0x09, 80 | 0x00, 0xA0, 0x06, 0x00, 0x40, 0x08, 0x01, 0x00, 0xFC, 0x00, 0x7F, 0x42, 81 | 0x04, 0x08, 0x10, 0x20, 0x42, 0xFE, 0x0C, 0x41, 0x04, 0x30, 0x8C, 0x08, 82 | 0x21, 0x04, 0x10, 0x60, 0x24, 0x94, 0x92, 0x52, 0x40, 0x18, 0x20, 0x82, 83 | 0x10, 0x40, 0xC4, 0x10, 0x82, 0x08, 0xC0, 0x61, 0x24, 0x30 }; 84 | 85 | const GFXglyph FreeMonoOblique9pt7bGlyphs[] PROGMEM = { 86 | { 0, 0, 0, 11, 0, 1 }, // 0x20 ' ' 87 | { 0, 4, 11, 11, 4, -10 }, // 0x21 '!' 88 | { 6, 5, 5, 11, 4, -10 }, // 0x22 '"' 89 | { 10, 9, 12, 11, 2, -10 }, // 0x23 '#' 90 | { 24, 8, 12, 11, 3, -10 }, // 0x24 '$' 91 | { 36, 9, 11, 11, 2, -10 }, // 0x25 '%' 92 | { 49, 7, 10, 11, 2, -9 }, // 0x26 '&' 93 | { 58, 2, 5, 11, 6, -10 }, // 0x27 ''' 94 | { 60, 4, 13, 11, 6, -10 }, // 0x28 '(' 95 | { 67, 4, 13, 11, 3, -10 }, // 0x29 ')' 96 | { 74, 7, 7, 11, 4, -10 }, // 0x2A '*' 97 | { 81, 9, 8, 11, 2, -8 }, // 0x2B '+' 98 | { 90, 4, 5, 11, 2, -1 }, // 0x2C ',' 99 | { 93, 9, 1, 11, 2, -5 }, // 0x2D '-' 100 | { 95, 2, 2, 11, 4, -1 }, // 0x2E '.' 101 | { 96, 9, 13, 11, 2, -11 }, // 0x2F '/' 102 | { 111, 7, 11, 11, 3, -10 }, // 0x30 '0' 103 | { 121, 7, 11, 11, 2, -10 }, // 0x31 '1' 104 | { 131, 9, 11, 11, 2, -10 }, // 0x32 '2' 105 | { 144, 9, 11, 11, 2, -10 }, // 0x33 '3' 106 | { 157, 8, 11, 11, 2, -10 }, // 0x34 '4' 107 | { 168, 9, 11, 11, 2, -10 }, // 0x35 '5' 108 | { 181, 8, 11, 11, 3, -10 }, // 0x36 '6' 109 | { 192, 7, 11, 11, 4, -10 }, // 0x37 '7' 110 | { 202, 8, 11, 11, 3, -10 }, // 0x38 '8' 111 | { 213, 8, 11, 11, 3, -10 }, // 0x39 '9' 112 | { 224, 3, 8, 11, 4, -7 }, // 0x3A ':' 113 | { 227, 5, 11, 11, 2, -7 }, // 0x3B ';' 114 | { 234, 9, 8, 11, 2, -8 }, // 0x3C '<' 115 | { 243, 9, 4, 11, 2, -6 }, // 0x3D '=' 116 | { 248, 9, 8, 11, 2, -8 }, // 0x3E '>' 117 | { 257, 7, 10, 11, 4, -9 }, // 0x3F '?' 118 | { 266, 7, 12, 11, 3, -10 }, // 0x40 '@' 119 | { 277, 11, 10, 11, 0, -9 }, // 0x41 'A' 120 | { 291, 10, 10, 11, 1, -9 }, // 0x42 'B' 121 | { 304, 9, 10, 11, 2, -9 }, // 0x43 'C' 122 | { 316, 10, 10, 11, 1, -9 }, // 0x44 'D' 123 | { 329, 10, 10, 11, 1, -9 }, // 0x45 'E' 124 | { 342, 11, 10, 11, 1, -9 }, // 0x46 'F' 125 | { 356, 9, 10, 11, 2, -9 }, // 0x47 'G' 126 | { 368, 11, 10, 11, 1, -9 }, // 0x48 'H' 127 | { 382, 9, 10, 11, 2, -9 }, // 0x49 'I' 128 | { 394, 11, 10, 11, 2, -9 }, // 0x4A 'J' 129 | { 408, 11, 10, 11, 1, -9 }, // 0x4B 'K' 130 | { 422, 10, 10, 11, 1, -9 }, // 0x4C 'L' 131 | { 435, 13, 10, 11, 0, -9 }, // 0x4D 'M' 132 | { 452, 11, 10, 11, 1, -9 }, // 0x4E 'N' 133 | { 466, 9, 10, 11, 2, -9 }, // 0x4F 'O' 134 | { 478, 10, 10, 11, 1, -9 }, // 0x50 'P' 135 | { 491, 9, 13, 11, 2, -9 }, // 0x51 'Q' 136 | { 506, 10, 10, 11, 1, -9 }, // 0x52 'R' 137 | { 519, 9, 10, 11, 2, -9 }, // 0x53 'S' 138 | { 531, 9, 10, 11, 3, -9 }, // 0x54 'T' 139 | { 543, 10, 10, 11, 2, -9 }, // 0x55 'U' 140 | { 556, 11, 10, 11, 2, -9 }, // 0x56 'V' 141 | { 570, 11, 10, 11, 2, -9 }, // 0x57 'W' 142 | { 584, 11, 10, 11, 1, -9 }, // 0x58 'X' 143 | { 598, 9, 10, 11, 3, -9 }, // 0x59 'Y' 144 | { 610, 9, 10, 11, 2, -9 }, // 0x5A 'Z' 145 | { 622, 5, 13, 11, 5, -10 }, // 0x5B '[' 146 | { 631, 4, 14, 11, 4, -11 }, // 0x5C '\' 147 | { 638, 5, 13, 11, 2, -10 }, // 0x5D ']' 148 | { 647, 7, 5, 11, 3, -10 }, // 0x5E '^' 149 | { 652, 11, 1, 11, 0, 2 }, // 0x5F '_' 150 | { 654, 2, 3, 11, 5, -11 }, // 0x60 '`' 151 | { 655, 9, 8, 11, 2, -7 }, // 0x61 'a' 152 | { 664, 11, 11, 11, 0, -10 }, // 0x62 'b' 153 | { 680, 10, 8, 11, 2, -7 }, // 0x63 'c' 154 | { 690, 9, 11, 11, 2, -10 }, // 0x64 'd' 155 | { 703, 9, 8, 11, 2, -7 }, // 0x65 'e' 156 | { 712, 10, 11, 11, 2, -10 }, // 0x66 'f' 157 | { 726, 10, 11, 11, 2, -7 }, // 0x67 'g' 158 | { 740, 10, 11, 11, 1, -10 }, // 0x68 'h' 159 | { 754, 8, 11, 11, 2, -10 }, // 0x69 'i' 160 | { 765, 9, 14, 11, 1, -10 }, // 0x6A 'j' 161 | { 781, 9, 11, 11, 1, -10 }, // 0x6B 'k' 162 | { 794, 8, 11, 11, 2, -10 }, // 0x6C 'l' 163 | { 805, 11, 8, 11, 0, -7 }, // 0x6D 'm' 164 | { 816, 9, 8, 11, 1, -7 }, // 0x6E 'n' 165 | { 825, 9, 8, 11, 2, -7 }, // 0x6F 'o' 166 | { 834, 11, 11, 11, 0, -7 }, // 0x70 'p' 167 | { 850, 10, 11, 11, 2, -7 }, // 0x71 'q' 168 | { 864, 9, 8, 11, 2, -7 }, // 0x72 'r' 169 | { 873, 8, 8, 11, 2, -7 }, // 0x73 's' 170 | { 881, 7, 10, 11, 2, -9 }, // 0x74 't' 171 | { 890, 9, 8, 11, 2, -7 }, // 0x75 'u' 172 | { 899, 10, 8, 11, 2, -7 }, // 0x76 'v' 173 | { 909, 10, 8, 11, 2, -7 }, // 0x77 'w' 174 | { 919, 10, 8, 11, 1, -7 }, // 0x78 'x' 175 | { 929, 12, 11, 11, 0, -7 }, // 0x79 'y' 176 | { 946, 8, 8, 11, 2, -7 }, // 0x7A 'z' 177 | { 954, 6, 13, 11, 4, -10 }, // 0x7B '{' 178 | { 964, 3, 12, 11, 5, -9 }, // 0x7C '|' 179 | { 969, 6, 13, 11, 3, -10 }, // 0x7D '}' 180 | { 979, 7, 3, 11, 3, -6 } }; // 0x7E '~' 181 | 182 | const GFXfont FreeMonoOblique9pt7b PROGMEM = { 183 | (uint8_t *)FreeMonoOblique9pt7bBitmaps, 184 | (GFXglyph *)FreeMonoOblique9pt7bGlyphs, 185 | 0x20, 0x7E, 18 }; 186 | 187 | // Approx. 1654 bytes 188 | -------------------------------------------------------------------------------- /lib/src/Fonts/Font7srle.c: -------------------------------------------------------------------------------- 1 | // Font 7 2 | // 3 | // This font has been 8 bit Run Length Encoded to save FLASH space 4 | // 5 | // This is a 7 segment font intended to display numbers and time 6 | // This font only contains characters [space] 0 1 2 3 4 5 6 7 8 9 : . - 7 | // All other characters print as a space 8 | 9 | #include 10 | 11 | 12 | PROGMEM const unsigned char widtbl_f7s[96] = // character width table 13 | { 14 | 12, 12, 12, 12, 12, 12, 12, 12, // char 32 - 39 15 | 12, 12, 12, 12, 12, 17, 12, 12, // char 40 - 47 16 | 32, 32, 32, 32, 32, 32, 32, 32, // char 48 - 55 17 | 32, 32, 12, 12, 12, 12, 12, 12, // char 56 - 63 18 | 12, 12, 12, 12, 12, 12, 12, 12, // char 64 - 71 19 | 12, 12, 12, 12, 12, 12, 12, 12, // char 72 - 79 20 | 12, 12, 12, 12, 12, 12, 12, 12, // char 80 - 87 21 | 12, 12, 12, 12, 12, 12, 12, 12, // char 88 - 95 22 | 12, 12, 12, 12, 12, 12, 12, 12, // char 96 - 103 23 | 12, 12, 12, 12, 12, 12, 12, 12, // char 104 - 111 24 | 12, 12, 12, 12, 12, 12, 12, 12, // char 112 - 119 25 | 12, 12, 12, 12, 12, 12, 12, 12 // char 120 - 127 26 | }; 27 | 28 | // Row format, MSB left 29 | 30 | PROGMEM const unsigned char chr_f7s_20[] = 31 | { 32 | 0x7F, 0x7F, 0x7F, 0x7F, 0x3F 33 | }; 34 | 35 | PROGMEM const unsigned char chr_f7s_2D[] = 36 | { 37 | 0x7F, 0x7F, 0x45, 0x8A, 0x05, 0x8A, 0x05, 0x8A, 38 | 0x05, 0x8A, 0x7F, 0x7F, 0x7F, 0x2B 39 | }; 40 | 41 | PROGMEM const unsigned char chr_f7s_2E[] = 42 | { 43 | 0x7F, 0x7F, 0x7F, 0x7B, 0x82, 0x07, 0x84, 0x06, 44 | 0x84, 0x06, 0x84, 0x07, 0x82, 0x10 45 | }; 46 | 47 | PROGMEM const unsigned char chr_f7s_30[] = 48 | { 49 | 0x27, 0x8E, 0x0F, 0x90, 0x0D, 0x92, 0x0D, 0x90, 50 | 0x01, 0x80, 0x08, 0x81, 0x01, 0x8E, 0x01, 0x82, 51 | 0x06, 0x83, 0x10, 0x84, 0x04, 0x85, 0x0E, 0x85, 52 | 0x04, 0x85, 0x0E, 0x85, 0x04, 0x85, 0x0E, 0x85, 53 | 0x04, 0x85, 0x0E, 0x85, 0x04, 0x85, 0x0E, 0x85, 54 | 0x04, 0x85, 0x0E, 0x85, 0x04, 0x85, 0x0E, 0x85, 55 | 0x04, 0x85, 0x0E, 0x85, 0x04, 0x85, 0x0E, 0x85, 56 | 0x04, 0x85, 0x0E, 0x85, 0x04, 0x85, 0x0E, 0x85, 57 | 0x04, 0x85, 0x0E, 0x85, 0x04, 0x85, 0x0E, 0x85, 58 | 0x04, 0x84, 0x10, 0x84, 0x04, 0x82, 0x14, 0x82, 59 | 0x04, 0x80, 0x18, 0x80, 0x24, 0x80, 0x1E, 0x82, 60 | 0x15, 0x81, 0x04, 0x84, 0x11, 0x83, 0x04, 0x85, 61 | 0x0E, 0x85, 0x04, 0x85, 0x0E, 0x85, 0x04, 0x85, 62 | 0x0E, 0x85, 0x04, 0x85, 0x0E, 0x85, 0x04, 0x85, 63 | 0x0E, 0x85, 0x04, 0x85, 0x0E, 0x85, 0x04, 0x85, 64 | 0x0E, 0x85, 0x04, 0x85, 0x0E, 0x85, 0x04, 0x85, 65 | 0x0E, 0x85, 0x04, 0x85, 0x0E, 0x85, 0x04, 0x85, 66 | 0x0E, 0x85, 0x04, 0x85, 0x0E, 0x85, 0x04, 0x85, 67 | 0x0E, 0x85, 0x04, 0x85, 0x0E, 0x85, 0x05, 0x83, 68 | 0x10, 0x83, 0x07, 0x81, 0x01, 0x8E, 0x01, 0x81, 69 | 0x0B, 0x90, 0x0D, 0x92, 0x0D, 0x90, 0x0F, 0x8E, 70 | 0x28 71 | }; 72 | 73 | PROGMEM const unsigned char chr_f7s_31[] = 74 | { 75 | 0x7F, 0x19, 0x80, 0x1D, 0x82, 0x1B, 0x84, 0x19, 76 | 0x85, 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 0x19, 77 | 0x85, 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 0x19, 78 | 0x85, 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 0x19, 79 | 0x85, 0x1B, 0x83, 0x1D, 0x81, 0x1E, 0x80, 0x5D, 80 | 0x81, 0x1B, 0x83, 0x19, 0x85, 0x19, 0x85, 0x19, 81 | 0x85, 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 0x19, 82 | 0x85, 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 0x19, 83 | 0x85, 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 0x1A, 84 | 0x83, 0x1C, 0x81, 0x7F, 0x24 85 | }; 86 | 87 | PROGMEM const unsigned char chr_f7s_32[] = 88 | { 89 | 0x27, 0x8E, 0x0F, 0x90, 0x0D, 0x92, 0x0D, 0x90, 90 | 0x01, 0x80, 0x0C, 0x8E, 0x01, 0x82, 0x1B, 0x84, 91 | 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 92 | 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 93 | 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 94 | 0x19, 0x85, 0x1A, 0x84, 0x0A, 0x8E, 0x02, 0x82, 95 | 0x08, 0x92, 0x02, 0x80, 0x06, 0x96, 0x06, 0x80, 96 | 0x01, 0x94, 0x07, 0x82, 0x01, 0x90, 0x09, 0x84, 97 | 0x1A, 0x85, 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 98 | 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 99 | 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 100 | 0x19, 0x85, 0x19, 0x85, 0x1A, 0x83, 0x1C, 0x81, 101 | 0x01, 0x8E, 0x0F, 0x90, 0x0D, 0x92, 0x0D, 0x90, 102 | 0x0F, 0x8E, 0x28 103 | }; 104 | 105 | PROGMEM const unsigned char chr_f7s_33[] = 106 | { 107 | 0x27, 0x8E, 0x0F, 0x90, 0x0D, 0x92, 0x0D, 0x90, 108 | 0x01, 0x80, 0x0C, 0x8E, 0x01, 0x82, 0x1B, 0x84, 109 | 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 110 | 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 111 | 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 112 | 0x19, 0x85, 0x1A, 0x84, 0x0A, 0x8E, 0x02, 0x82, 113 | 0x08, 0x92, 0x02, 0x80, 0x06, 0x96, 0x09, 0x94, 114 | 0x0C, 0x90, 0x02, 0x81, 0x1B, 0x83, 0x19, 0x85, 115 | 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 116 | 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 117 | 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 118 | 0x19, 0x85, 0x1A, 0x83, 0x0B, 0x8E, 0x01, 0x81, 119 | 0x0B, 0x90, 0x0D, 0x92, 0x0D, 0x90, 0x0F, 0x8E, 120 | 0x28 121 | }; 122 | 123 | PROGMEM const unsigned char chr_f7s_34[] = 124 | { 125 | 0x7F, 0x19, 0x80, 0x08, 0x81, 0x12, 0x82, 0x06, 126 | 0x83, 0x10, 0x84, 0x04, 0x85, 0x0E, 0x85, 0x04, 127 | 0x85, 0x0E, 0x85, 0x04, 0x85, 0x0E, 0x85, 0x04, 128 | 0x85, 0x0E, 0x85, 0x04, 0x85, 0x0E, 0x85, 0x04, 129 | 0x85, 0x0E, 0x85, 0x04, 0x85, 0x0E, 0x85, 0x04, 130 | 0x85, 0x0E, 0x85, 0x04, 0x85, 0x0E, 0x85, 0x04, 131 | 0x85, 0x0E, 0x85, 0x04, 0x85, 0x0E, 0x85, 0x04, 132 | 0x85, 0x0E, 0x85, 0x04, 0x85, 0x0E, 0x85, 0x04, 133 | 0x84, 0x10, 0x84, 0x04, 0x82, 0x02, 0x8E, 0x02, 134 | 0x82, 0x04, 0x80, 0x02, 0x92, 0x02, 0x80, 0x06, 135 | 0x96, 0x09, 0x94, 0x0C, 0x90, 0x02, 0x81, 0x1B, 136 | 0x83, 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 0x19, 137 | 0x85, 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 0x19, 138 | 0x85, 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 0x19, 139 | 0x85, 0x19, 0x85, 0x19, 0x85, 0x1A, 0x83, 0x1C, 140 | 0x81, 0x7F, 0x24 141 | }; 142 | 143 | PROGMEM const unsigned char chr_f7s_35[] = 144 | { 145 | 0x27, 0x8E, 0x0F, 0x90, 0x0D, 0x92, 0x0D, 0x90, 146 | 0x0B, 0x81, 0x01, 0x8E, 0x0B, 0x83, 0x1A, 0x85, 147 | 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 148 | 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 149 | 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 150 | 0x19, 0x84, 0x1A, 0x82, 0x02, 0x8E, 0x0A, 0x80, 151 | 0x02, 0x92, 0x0A, 0x96, 0x09, 0x94, 0x0C, 0x90, 152 | 0x02, 0x81, 0x1B, 0x83, 0x19, 0x85, 0x19, 0x85, 153 | 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 154 | 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 155 | 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 156 | 0x1A, 0x83, 0x0B, 0x8E, 0x01, 0x81, 0x0B, 0x90, 157 | 0x0D, 0x92, 0x0D, 0x90, 0x0F, 0x8E, 0x28 158 | }; 159 | 160 | PROGMEM const unsigned char chr_f7s_36[] = 161 | { 162 | 0x27, 0x8E, 0x0F, 0x90, 0x0D, 0x92, 0x0D, 0x90, 163 | 0x0B, 0x81, 0x01, 0x8E, 0x0B, 0x83, 0x1A, 0x85, 164 | 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 165 | 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 166 | 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 167 | 0x19, 0x84, 0x1A, 0x82, 0x02, 0x8E, 0x0A, 0x80, 168 | 0x02, 0x92, 0x0A, 0x96, 0x06, 0x80, 0x01, 0x94, 169 | 0x07, 0x82, 0x01, 0x90, 0x02, 0x81, 0x04, 0x84, 170 | 0x11, 0x83, 0x04, 0x85, 0x0E, 0x85, 0x04, 0x85, 171 | 0x0E, 0x85, 0x04, 0x85, 0x0E, 0x85, 0x04, 0x85, 172 | 0x0E, 0x85, 0x04, 0x85, 0x0E, 0x85, 0x04, 0x85, 173 | 0x0E, 0x85, 0x04, 0x85, 0x0E, 0x85, 0x04, 0x85, 174 | 0x0E, 0x85, 0x04, 0x85, 0x0E, 0x85, 0x04, 0x85, 175 | 0x0E, 0x85, 0x04, 0x85, 0x0E, 0x85, 0x04, 0x85, 176 | 0x0E, 0x85, 0x04, 0x85, 0x0E, 0x85, 0x04, 0x85, 177 | 0x0E, 0x85, 0x05, 0x83, 0x10, 0x83, 0x07, 0x81, 178 | 0x01, 0x8E, 0x01, 0x81, 0x0B, 0x90, 0x0D, 0x92, 179 | 0x0D, 0x90, 0x0F, 0x8E, 0x28 180 | }; 181 | 182 | PROGMEM const unsigned char chr_f7s_37[] = 183 | { 184 | 0x27, 0x8E, 0x0F, 0x90, 0x0D, 0x92, 0x0D, 0x90, 185 | 0x01, 0x80, 0x0C, 0x8E, 0x01, 0x82, 0x1B, 0x84, 186 | 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 187 | 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 188 | 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 189 | 0x19, 0x85, 0x1A, 0x84, 0x1C, 0x82, 0x1E, 0x80, 190 | 0x5D, 0x81, 0x1B, 0x83, 0x19, 0x85, 0x19, 0x85, 191 | 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 192 | 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 193 | 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 194 | 0x1A, 0x83, 0x1C, 0x81, 0x7F, 0x24 195 | }; 196 | 197 | PROGMEM const unsigned char chr_f7s_38[] = 198 | { 199 | 0x27, 0x8E, 0x0F, 0x90, 0x0D, 0x92, 0x0D, 0x90, 200 | 0x01, 0x80, 0x08, 0x81, 0x01, 0x8E, 0x01, 0x82, 201 | 0x06, 0x83, 0x10, 0x84, 0x04, 0x85, 0x0E, 0x85, 202 | 0x04, 0x85, 0x0E, 0x85, 0x04, 0x85, 0x0E, 0x85, 203 | 0x04, 0x85, 0x0E, 0x85, 0x04, 0x85, 0x0E, 0x85, 204 | 0x04, 0x85, 0x0E, 0x85, 0x04, 0x85, 0x0E, 0x85, 205 | 0x04, 0x85, 0x0E, 0x85, 0x04, 0x85, 0x0E, 0x85, 206 | 0x04, 0x85, 0x0E, 0x85, 0x04, 0x85, 0x0E, 0x85, 207 | 0x04, 0x85, 0x0E, 0x85, 0x04, 0x85, 0x0E, 0x85, 208 | 0x04, 0x84, 0x10, 0x84, 0x04, 0x82, 0x02, 0x8E, 209 | 0x02, 0x82, 0x04, 0x80, 0x02, 0x92, 0x02, 0x80, 210 | 0x06, 0x96, 0x06, 0x80, 0x01, 0x94, 0x07, 0x82, 211 | 0x01, 0x90, 0x02, 0x81, 0x04, 0x84, 0x11, 0x83, 212 | 0x04, 0x85, 0x0E, 0x85, 0x04, 0x85, 0x0E, 0x85, 213 | 0x04, 0x85, 0x0E, 0x85, 0x04, 0x85, 0x0E, 0x85, 214 | 0x04, 0x85, 0x0E, 0x85, 0x04, 0x85, 0x0E, 0x85, 215 | 0x04, 0x85, 0x0E, 0x85, 0x04, 0x85, 0x0E, 0x85, 216 | 0x04, 0x85, 0x0E, 0x85, 0x04, 0x85, 0x0E, 0x85, 217 | 0x04, 0x85, 0x0E, 0x85, 0x04, 0x85, 0x0E, 0x85, 218 | 0x04, 0x85, 0x0E, 0x85, 0x04, 0x85, 0x0E, 0x85, 219 | 0x05, 0x83, 0x10, 0x83, 0x07, 0x81, 0x01, 0x8E, 220 | 0x01, 0x81, 0x0B, 0x90, 0x0D, 0x92, 0x0D, 0x90, 221 | 0x0F, 0x8E, 0x28 222 | }; 223 | 224 | PROGMEM const unsigned char chr_f7s_39[] = 225 | { 226 | 0x27, 0x8E, 0x0F, 0x90, 0x0D, 0x92, 0x0D, 0x90, 227 | 0x01, 0x80, 0x08, 0x81, 0x01, 0x8E, 0x01, 0x82, 228 | 0x06, 0x83, 0x10, 0x84, 0x04, 0x85, 0x0E, 0x85, 229 | 0x04, 0x85, 0x0E, 0x85, 0x04, 0x85, 0x0E, 0x85, 230 | 0x04, 0x85, 0x0E, 0x85, 0x04, 0x85, 0x0E, 0x85, 231 | 0x04, 0x85, 0x0E, 0x85, 0x04, 0x85, 0x0E, 0x85, 232 | 0x04, 0x85, 0x0E, 0x85, 0x04, 0x85, 0x0E, 0x85, 233 | 0x04, 0x85, 0x0E, 0x85, 0x04, 0x85, 0x0E, 0x85, 234 | 0x04, 0x85, 0x0E, 0x85, 0x04, 0x85, 0x0E, 0x85, 235 | 0x04, 0x84, 0x10, 0x84, 0x04, 0x82, 0x02, 0x8E, 236 | 0x02, 0x82, 0x04, 0x80, 0x02, 0x92, 0x02, 0x80, 237 | 0x06, 0x96, 0x09, 0x94, 0x0C, 0x90, 0x02, 0x81, 238 | 0x1B, 0x83, 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 239 | 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 240 | 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 241 | 0x19, 0x85, 0x19, 0x85, 0x19, 0x85, 0x1A, 0x83, 242 | 0x0B, 0x8E, 0x01, 0x81, 0x0B, 0x90, 0x0D, 0x92, 243 | 0x0D, 0x90, 0x0F, 0x8E, 0x28 244 | }; 245 | 246 | PROGMEM const unsigned char chr_f7s_3A[] = 247 | { 248 | 0x7F, 0x1F, 0x82, 0x07, 0x84, 0x06, 0x84, 0x06, 249 | 0x84, 0x07, 0x82, 0x7F, 0x18, 0x82, 0x07, 0x84, 250 | 0x06, 0x84, 0x06, 0x84, 0x07, 0x82, 0x7F, 0x20 251 | }; 252 | PROGMEM const unsigned char* const chrtbl_f7s[96] = // character pointer table 253 | { 254 | chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, 255 | chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_2D, chr_f7s_2E, chr_f7s_20, 256 | chr_f7s_30, chr_f7s_31, chr_f7s_32, chr_f7s_33, chr_f7s_34, chr_f7s_35, chr_f7s_36, chr_f7s_37, 257 | chr_f7s_38, chr_f7s_39, chr_f7s_3A, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, 258 | chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, 259 | chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, 260 | chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, 261 | chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, 262 | chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, 263 | chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, 264 | chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, 265 | chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20, chr_f7s_20 266 | }; 267 | -------------------------------------------------------------------------------- /lib/src/Fonts/GFXFF/FreeMonoBold9pt7b.h: -------------------------------------------------------------------------------- 1 | const uint8_t FreeMonoBold9pt7bBitmaps[] PROGMEM = { 2 | 0xFF, 0xFF, 0xD2, 0x1F, 0x80, 0xEC, 0x89, 0x12, 0x24, 0x40, 0x36, 0x36, 3 | 0x36, 0x7F, 0x7F, 0x36, 0xFF, 0xFF, 0x3C, 0x3C, 0x3C, 0x00, 0x18, 0xFF, 4 | 0xFE, 0x3C, 0x1F, 0x1F, 0x83, 0x46, 0x8D, 0xF0, 0xC1, 0x83, 0x00, 0x61, 5 | 0x22, 0x44, 0x86, 0x67, 0x37, 0x11, 0x22, 0x4C, 0x70, 0x3C, 0x7E, 0x60, 6 | 0x60, 0x30, 0x7B, 0xDF, 0xCE, 0xFF, 0x7F, 0xC9, 0x24, 0x37, 0x66, 0xCC, 7 | 0xCC, 0xCC, 0x66, 0x31, 0xCE, 0x66, 0x33, 0x33, 0x33, 0x66, 0xC8, 0x18, 8 | 0x18, 0xFF, 0xFF, 0x3C, 0x3C, 0x66, 0x18, 0x18, 0x18, 0xFF, 0xFF, 0x18, 9 | 0x18, 0x18, 0x18, 0x6B, 0x48, 0xFF, 0xFF, 0xC0, 0xF0, 0x02, 0x0C, 0x18, 10 | 0x60, 0xC3, 0x06, 0x0C, 0x30, 0x61, 0x83, 0x0C, 0x18, 0x20, 0x00, 0x38, 11 | 0xFB, 0xBE, 0x3C, 0x78, 0xF1, 0xE3, 0xC7, 0xDD, 0xF1, 0xC0, 0x38, 0xF3, 12 | 0x60, 0xC1, 0x83, 0x06, 0x0C, 0x18, 0xFD, 0xF8, 0x3C, 0xFE, 0xC7, 0x03, 13 | 0x03, 0x06, 0x0C, 0x18, 0x70, 0xE3, 0xFF, 0xFF, 0x7C, 0xFE, 0x03, 0x03, 14 | 0x03, 0x1E, 0x1E, 0x07, 0x03, 0x03, 0xFE, 0x7C, 0x1C, 0x38, 0xB1, 0x64, 15 | 0xD9, 0xBF, 0xFF, 0x3E, 0x7C, 0x7E, 0x3F, 0x18, 0x0F, 0xC7, 0xF3, 0x1C, 16 | 0x06, 0x03, 0xC3, 0xFF, 0x9F, 0x80, 0x0F, 0x3F, 0x30, 0x60, 0x60, 0xDC, 17 | 0xFE, 0xE3, 0xC3, 0x63, 0x7E, 0x3C, 0xFF, 0xFF, 0xC3, 0x03, 0x06, 0x06, 18 | 0x06, 0x0C, 0x0C, 0x0C, 0x18, 0x38, 0xFB, 0x1E, 0x3C, 0x6F, 0x9F, 0x63, 19 | 0xC7, 0x8F, 0xF1, 0xC0, 0x3C, 0x7E, 0xE6, 0xC3, 0xC3, 0xE7, 0x7F, 0x3B, 20 | 0x06, 0x0E, 0xFC, 0xF0, 0xF0, 0x0F, 0x6C, 0x00, 0x1A, 0xD2, 0x00, 0x01, 21 | 0x83, 0x87, 0x0E, 0x0F, 0x80, 0xE0, 0x1C, 0x03, 0xFF, 0xFF, 0xC0, 0x00, 22 | 0x0F, 0xFF, 0xFC, 0xC0, 0x78, 0x0F, 0x01, 0xE0, 0xF9, 0xE3, 0xC1, 0x80, 23 | 0x7C, 0xFE, 0xC7, 0x03, 0x0E, 0x1C, 0x00, 0x00, 0x00, 0x30, 0x30, 0x1E, 24 | 0x1F, 0x1C, 0xDC, 0x6C, 0x76, 0x7B, 0x6D, 0xB6, 0xDB, 0x6F, 0xF3, 0xFC, 25 | 0x06, 0x33, 0xF8, 0x78, 0x3C, 0x07, 0xC0, 0x38, 0x05, 0x81, 0xB0, 0x36, 26 | 0x0F, 0xE1, 0xFC, 0x71, 0xDF, 0x7F, 0xEF, 0x80, 0xFF, 0x3F, 0xE6, 0x19, 27 | 0x86, 0x7F, 0x1F, 0xE6, 0x1D, 0x83, 0x60, 0xFF, 0xFF, 0xF0, 0x1F, 0xBF, 28 | 0xD8, 0xF8, 0x3C, 0x06, 0x03, 0x01, 0x80, 0x61, 0xBF, 0xC7, 0xC0, 0xFE, 29 | 0x3F, 0xE6, 0x19, 0x83, 0x60, 0xD8, 0x36, 0x0D, 0x83, 0x61, 0xBF, 0xEF, 30 | 0xE0, 0xFF, 0xFF, 0xD8, 0x6D, 0xB7, 0xC3, 0xE1, 0xB0, 0xC3, 0x61, 0xFF, 31 | 0xFF, 0xE0, 0xFF, 0xFF, 0xD8, 0x6D, 0xB7, 0xC3, 0xE1, 0xB0, 0xC0, 0x60, 32 | 0x7C, 0x3E, 0x00, 0x1F, 0x9F, 0xE6, 0x1B, 0x06, 0xC0, 0x30, 0x0C, 0x7F, 33 | 0x1F, 0xE1, 0x9F, 0xE3, 0xF0, 0xF7, 0xFB, 0xD8, 0xCC, 0x66, 0x33, 0xF9, 34 | 0xFC, 0xC6, 0x63, 0x7B, 0xFD, 0xE0, 0xFF, 0xF3, 0x0C, 0x30, 0xC3, 0x0C, 35 | 0x33, 0xFF, 0xC0, 0x1F, 0xC7, 0xF0, 0x30, 0x0C, 0x03, 0x00, 0xCC, 0x33, 36 | 0x0C, 0xC7, 0x3F, 0x87, 0xC0, 0xF7, 0xBD, 0xE6, 0x61, 0xB0, 0x78, 0x1F, 37 | 0x06, 0xE1, 0x98, 0x63, 0x3C, 0xFF, 0x3C, 0xFC, 0x7E, 0x0C, 0x06, 0x03, 38 | 0x01, 0x80, 0xC6, 0x63, 0x31, 0xFF, 0xFF, 0xE0, 0xE0, 0xFE, 0x3D, 0xC7, 39 | 0x3D, 0xE7, 0xBC, 0xD7, 0x9B, 0xB3, 0x76, 0x60, 0xDE, 0x3F, 0xC7, 0x80, 40 | 0xE1, 0xFE, 0x3D, 0xE3, 0x3C, 0x66, 0xCC, 0xDD, 0x99, 0xB3, 0x1E, 0x63, 41 | 0xDE, 0x3B, 0xC3, 0x00, 0x1F, 0x07, 0xF1, 0xC7, 0x70, 0x7C, 0x07, 0x80, 42 | 0xF0, 0x1F, 0x07, 0x71, 0xC7, 0xF0, 0x7C, 0x00, 0xFE, 0x7F, 0x98, 0x6C, 43 | 0x36, 0x1B, 0xF9, 0xF8, 0xC0, 0x60, 0x7C, 0x3E, 0x00, 0x1F, 0x07, 0xF1, 44 | 0xC7, 0x70, 0x7C, 0x07, 0x80, 0xF0, 0x1F, 0x07, 0x71, 0xC7, 0xF0, 0x7C, 45 | 0x0C, 0x33, 0xFE, 0x7F, 0x80, 0xFC, 0x7F, 0x18, 0xCC, 0x66, 0x73, 0xF1, 46 | 0xF0, 0xCC, 0x63, 0x7D, 0xFE, 0x60, 0x3F, 0xBF, 0xF0, 0x78, 0x0F, 0x03, 47 | 0xF8, 0x3F, 0x83, 0xC3, 0xFF, 0xBF, 0x80, 0xFF, 0xFF, 0xF6, 0x7B, 0x3D, 48 | 0x98, 0xC0, 0x60, 0x30, 0x18, 0x3F, 0x1F, 0x80, 0xF1, 0xFE, 0x3D, 0x83, 49 | 0x30, 0x66, 0x0C, 0xC1, 0x98, 0x33, 0x06, 0x60, 0xC7, 0xF0, 0x7C, 0x00, 50 | 0xFB, 0xFF, 0x7D, 0xC3, 0x18, 0xC3, 0x18, 0x36, 0x06, 0xC0, 0x50, 0x0E, 51 | 0x01, 0xC0, 0x10, 0x00, 0xFB, 0xFE, 0xF6, 0x0D, 0x93, 0x6E, 0xDB, 0xB7, 52 | 0xAD, 0xEE, 0x7B, 0x8E, 0xE3, 0x18, 0xF3, 0xFC, 0xF7, 0x38, 0xFC, 0x1E, 53 | 0x03, 0x01, 0xE0, 0xCC, 0x73, 0xBC, 0xFF, 0x3C, 0xF3, 0xFC, 0xF7, 0x38, 54 | 0xCC, 0x1E, 0x07, 0x80, 0xC0, 0x30, 0x0C, 0x0F, 0xC3, 0xF0, 0xFE, 0xFE, 55 | 0xC6, 0xCC, 0x18, 0x18, 0x30, 0x63, 0xC3, 0xFF, 0xFF, 0xFF, 0xCC, 0xCC, 56 | 0xCC, 0xCC, 0xCC, 0xFF, 0x01, 0x03, 0x06, 0x06, 0x0C, 0x0C, 0x18, 0x18, 57 | 0x30, 0x30, 0x60, 0x60, 0xC0, 0x80, 0xFF, 0x33, 0x33, 0x33, 0x33, 0x33, 58 | 0xFF, 0x10, 0x71, 0xE3, 0x6C, 0x70, 0x40, 0xFF, 0xFF, 0xFC, 0x88, 0x80, 59 | 0x7E, 0x3F, 0x8F, 0xCF, 0xEE, 0x36, 0x1B, 0xFE, 0xFF, 0xE0, 0x38, 0x06, 60 | 0x01, 0xBC, 0x7F, 0x9C, 0x76, 0x0D, 0x83, 0x71, 0xFF, 0xEE, 0xF0, 0x3F, 61 | 0xBF, 0xF8, 0x78, 0x3C, 0x07, 0x05, 0xFE, 0x7E, 0x03, 0x80, 0xE0, 0x18, 62 | 0xF6, 0x7F, 0xB8, 0xEC, 0x1B, 0x06, 0xE3, 0x9F, 0xF3, 0xFC, 0x3E, 0x3F, 63 | 0xB0, 0xFF, 0xFF, 0xFE, 0x01, 0xFE, 0x7E, 0x1F, 0x3F, 0x30, 0x7E, 0x7E, 64 | 0x30, 0x30, 0x30, 0x30, 0xFE, 0xFE, 0x3F, 0xBF, 0xF9, 0xD8, 0x6C, 0x37, 65 | 0x39, 0xFC, 0x76, 0x03, 0x01, 0x8F, 0xC7, 0xC0, 0xE0, 0x70, 0x18, 0x0D, 66 | 0xC7, 0xF3, 0x99, 0x8C, 0xC6, 0x63, 0x7B, 0xFD, 0xE0, 0x18, 0x18, 0x00, 67 | 0x78, 0x78, 0x18, 0x18, 0x18, 0x18, 0xFF, 0xFF, 0x18, 0x60, 0x3F, 0xFC, 68 | 0x30, 0xC3, 0x0C, 0x30, 0xC3, 0x0F, 0xFF, 0x80, 0xE0, 0x70, 0x18, 0x0D, 69 | 0xE6, 0xF3, 0xE1, 0xE0, 0xF8, 0x6E, 0x73, 0xF9, 0xE0, 0x78, 0x78, 0x18, 70 | 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xFF, 0xFF, 0xFD, 0x9F, 0xF9, 0x9B, 71 | 0x33, 0x66, 0x6C, 0xCD, 0xBD, 0xFF, 0xBF, 0xEE, 0x7F, 0x98, 0xCC, 0x66, 72 | 0x33, 0x1B, 0xDF, 0xEF, 0x3E, 0x3F, 0xB8, 0xF8, 0x3C, 0x1F, 0x1D, 0xFC, 73 | 0x7C, 0xEF, 0x1F, 0xF9, 0xC3, 0xB0, 0x36, 0x06, 0xE1, 0xDF, 0xF3, 0x78, 74 | 0x60, 0x0C, 0x03, 0xE0, 0x7C, 0x00, 0x1E, 0xEF, 0xFF, 0x87, 0x60, 0x6C, 75 | 0x0D, 0xC3, 0x9F, 0xF0, 0xF6, 0x00, 0xC0, 0x18, 0x0F, 0x81, 0xF0, 0x77, 76 | 0xBF, 0xCF, 0x06, 0x03, 0x01, 0x83, 0xF9, 0xFC, 0x3F, 0xFF, 0xC3, 0xFC, 77 | 0x3F, 0xC3, 0xFF, 0xFC, 0x60, 0x60, 0x60, 0xFE, 0xFE, 0x60, 0x60, 0x60, 78 | 0x61, 0x7F, 0x3E, 0xE7, 0x73, 0x98, 0xCC, 0x66, 0x33, 0x19, 0xFE, 0x7F, 79 | 0xFB, 0xFF, 0x7C, 0xC6, 0x18, 0xC1, 0xB0, 0x36, 0x03, 0x80, 0x70, 0xF1, 80 | 0xFE, 0x3D, 0xBB, 0x37, 0x63, 0xF8, 0x77, 0x0E, 0xE1, 0x8C, 0xF7, 0xFB, 81 | 0xCD, 0x83, 0x83, 0xC3, 0xBB, 0xDF, 0xEF, 0xF3, 0xFC, 0xF6, 0x18, 0xCC, 82 | 0x33, 0x07, 0x81, 0xE0, 0x30, 0x0C, 0x06, 0x0F, 0xC3, 0xF0, 0xFF, 0xFF, 83 | 0x30, 0xC3, 0x0C, 0x7F, 0xFF, 0x37, 0x66, 0x66, 0xCC, 0x66, 0x66, 0x73, 84 | 0xFF, 0xFF, 0xFF, 0xF0, 0xCE, 0x66, 0x66, 0x33, 0x66, 0x66, 0xEC, 0x70, 85 | 0x7C, 0xF3, 0xC0, 0xC0 }; 86 | 87 | const GFXglyph FreeMonoBold9pt7bGlyphs[] PROGMEM = { 88 | { 0, 0, 0, 11, 0, 1 }, // 0x20 ' ' 89 | { 0, 3, 11, 11, 4, -10 }, // 0x21 '!' 90 | { 5, 7, 5, 11, 2, -10 }, // 0x22 '"' 91 | { 10, 8, 12, 11, 1, -10 }, // 0x23 '#' 92 | { 22, 7, 14, 11, 2, -11 }, // 0x24 '$' 93 | { 35, 7, 11, 11, 2, -10 }, // 0x25 '%' 94 | { 45, 8, 10, 11, 1, -9 }, // 0x26 '&' 95 | { 55, 3, 5, 11, 4, -10 }, // 0x27 ''' 96 | { 57, 4, 14, 11, 5, -10 }, // 0x28 '(' 97 | { 64, 4, 14, 11, 2, -10 }, // 0x29 ')' 98 | { 71, 8, 7, 11, 2, -10 }, // 0x2A '*' 99 | { 78, 8, 9, 11, 2, -8 }, // 0x2B '+' 100 | { 87, 3, 5, 11, 3, -1 }, // 0x2C ',' 101 | { 89, 9, 2, 11, 1, -5 }, // 0x2D '-' 102 | { 92, 2, 2, 11, 4, -1 }, // 0x2E '.' 103 | { 93, 7, 15, 11, 2, -12 }, // 0x2F '/' 104 | { 107, 7, 12, 11, 2, -11 }, // 0x30 '0' 105 | { 118, 7, 11, 11, 2, -10 }, // 0x31 '1' 106 | { 128, 8, 12, 11, 1, -11 }, // 0x32 '2' 107 | { 140, 8, 12, 11, 2, -11 }, // 0x33 '3' 108 | { 152, 7, 10, 11, 2, -9 }, // 0x34 '4' 109 | { 161, 9, 11, 11, 1, -10 }, // 0x35 '5' 110 | { 174, 8, 12, 11, 2, -11 }, // 0x36 '6' 111 | { 186, 8, 11, 11, 1, -10 }, // 0x37 '7' 112 | { 197, 7, 12, 11, 2, -11 }, // 0x38 '8' 113 | { 208, 8, 12, 11, 2, -11 }, // 0x39 '9' 114 | { 220, 2, 8, 11, 4, -7 }, // 0x3A ':' 115 | { 222, 3, 11, 11, 3, -7 }, // 0x3B ';' 116 | { 227, 9, 8, 11, 1, -8 }, // 0x3C '<' 117 | { 236, 9, 6, 11, 1, -7 }, // 0x3D '=' 118 | { 243, 9, 8, 11, 1, -8 }, // 0x3E '>' 119 | { 252, 8, 11, 11, 2, -10 }, // 0x3F '?' 120 | { 263, 9, 15, 11, 1, -11 }, // 0x40 '@' 121 | { 280, 11, 11, 11, 0, -10 }, // 0x41 'A' 122 | { 296, 10, 11, 11, 1, -10 }, // 0x42 'B' 123 | { 310, 9, 11, 11, 1, -10 }, // 0x43 'C' 124 | { 323, 10, 11, 11, 0, -10 }, // 0x44 'D' 125 | { 337, 9, 11, 11, 1, -10 }, // 0x45 'E' 126 | { 350, 9, 11, 11, 1, -10 }, // 0x46 'F' 127 | { 363, 10, 11, 11, 1, -10 }, // 0x47 'G' 128 | { 377, 9, 11, 11, 1, -10 }, // 0x48 'H' 129 | { 390, 6, 11, 11, 3, -10 }, // 0x49 'I' 130 | { 399, 10, 11, 11, 1, -10 }, // 0x4A 'J' 131 | { 413, 10, 11, 11, 1, -10 }, // 0x4B 'K' 132 | { 427, 9, 11, 11, 1, -10 }, // 0x4C 'L' 133 | { 440, 11, 11, 11, 0, -10 }, // 0x4D 'M' 134 | { 456, 11, 11, 11, 0, -10 }, // 0x4E 'N' 135 | { 472, 11, 11, 11, 0, -10 }, // 0x4F 'O' 136 | { 488, 9, 11, 11, 1, -10 }, // 0x50 'P' 137 | { 501, 11, 14, 11, 0, -10 }, // 0x51 'Q' 138 | { 521, 9, 11, 11, 1, -10 }, // 0x52 'R' 139 | { 534, 9, 11, 11, 1, -10 }, // 0x53 'S' 140 | { 547, 9, 11, 11, 1, -10 }, // 0x54 'T' 141 | { 560, 11, 11, 11, 0, -10 }, // 0x55 'U' 142 | { 576, 11, 11, 11, 0, -10 }, // 0x56 'V' 143 | { 592, 10, 11, 11, 0, -10 }, // 0x57 'W' 144 | { 606, 10, 11, 11, 0, -10 }, // 0x58 'X' 145 | { 620, 10, 11, 11, 0, -10 }, // 0x59 'Y' 146 | { 634, 8, 11, 11, 2, -10 }, // 0x5A 'Z' 147 | { 645, 4, 14, 11, 5, -10 }, // 0x5B '[' 148 | { 652, 7, 15, 11, 2, -12 }, // 0x5C '\' 149 | { 666, 4, 14, 11, 2, -10 }, // 0x5D ']' 150 | { 673, 7, 6, 11, 2, -11 }, // 0x5E '^' 151 | { 679, 11, 2, 11, 0, 3 }, // 0x5F '_' 152 | { 682, 3, 3, 11, 3, -11 }, // 0x60 '`' 153 | { 684, 9, 8, 11, 1, -7 }, // 0x61 'a' 154 | { 693, 10, 11, 11, 0, -10 }, // 0x62 'b' 155 | { 707, 9, 8, 11, 1, -7 }, // 0x63 'c' 156 | { 716, 10, 11, 11, 1, -10 }, // 0x64 'd' 157 | { 730, 9, 8, 11, 1, -7 }, // 0x65 'e' 158 | { 739, 8, 11, 11, 2, -10 }, // 0x66 'f' 159 | { 750, 9, 12, 11, 1, -7 }, // 0x67 'g' 160 | { 764, 9, 11, 11, 1, -10 }, // 0x68 'h' 161 | { 777, 8, 11, 11, 2, -10 }, // 0x69 'i' 162 | { 788, 6, 15, 11, 2, -10 }, // 0x6A 'j' 163 | { 800, 9, 11, 11, 1, -10 }, // 0x6B 'k' 164 | { 813, 8, 11, 11, 2, -10 }, // 0x6C 'l' 165 | { 824, 11, 8, 11, 0, -7 }, // 0x6D 'm' 166 | { 835, 9, 8, 11, 1, -7 }, // 0x6E 'n' 167 | { 844, 9, 8, 11, 1, -7 }, // 0x6F 'o' 168 | { 853, 11, 12, 11, 0, -7 }, // 0x70 'p' 169 | { 870, 11, 12, 11, 0, -7 }, // 0x71 'q' 170 | { 887, 9, 8, 11, 1, -7 }, // 0x72 'r' 171 | { 896, 8, 8, 11, 2, -7 }, // 0x73 's' 172 | { 904, 8, 11, 11, 1, -10 }, // 0x74 't' 173 | { 915, 9, 8, 11, 1, -7 }, // 0x75 'u' 174 | { 924, 11, 8, 11, 0, -7 }, // 0x76 'v' 175 | { 935, 11, 8, 11, 0, -7 }, // 0x77 'w' 176 | { 946, 9, 8, 11, 1, -7 }, // 0x78 'x' 177 | { 955, 10, 12, 11, 0, -7 }, // 0x79 'y' 178 | { 970, 7, 8, 11, 2, -7 }, // 0x7A 'z' 179 | { 977, 4, 14, 11, 3, -10 }, // 0x7B '{' 180 | { 984, 2, 14, 11, 5, -10 }, // 0x7C '|' 181 | { 988, 4, 14, 11, 4, -10 }, // 0x7D '}' 182 | { 995, 9, 4, 11, 1, -6 } }; // 0x7E '~' 183 | 184 | const GFXfont FreeMonoBold9pt7b PROGMEM = { 185 | (uint8_t *)FreeMonoBold9pt7bBitmaps, 186 | (GFXglyph *)FreeMonoBold9pt7bGlyphs, 187 | 0x20, 0x7E, 18 }; 188 | 189 | // Approx. 1672 bytes 190 | --------------------------------------------------------------------------------