├── .gitattributes ├── .gitignore ├── CMakeLists.txt ├── Docs ├── Bluetooth_HM-13_en.pdf ├── NEO-M8-FW3_DataSheet_(UBX-15031086).pdf ├── NEO-M8_DataSheet_(UBX-13003366).pdf ├── PT1502.pdf ├── UBLOX_NMEA_Example.txt ├── bluepill-pinout.gif ├── bluepill-schematic.pdf ├── bluepill-schematics.png ├── ina219.pdf ├── maplemini.pdf ├── stm32f103_reference_manual.pdf ├── stm32f103xC_datasheet.pdf ├── stm32f103xb_datasheet.pdf ├── stm32f103xb_pinout.png ├── stm32f407_datasheet.pdf ├── stm32f407_reference_manual.pdf └── u-blox8-M8_ReceiverDescrProtSpec_(UBX-13003221)_Public.pdf ├── Fonts ├── 22x16 Numbers.pdn ├── 22x16 Numbers.png ├── 8x12_Numbers.png ├── FontGenerate.py └── Xwindows_8x12.png ├── Libs ├── AdafruitGFX │ ├── .gitignore │ ├── .travis.yml │ ├── Adafruit_GFX.cpp │ ├── Adafruit_GFX.h │ ├── Adafruit_SPITFT.cpp │ ├── Adafruit_SPITFT.h │ ├── Adafruit_SPITFT_Macros.h │ ├── Fonts │ │ ├── FreeMono12pt7b.h │ │ ├── FreeMono18pt7b.h │ │ ├── FreeMono24pt7b.h │ │ ├── FreeMono9pt7b.h │ │ ├── FreeMonoBold12pt7b.h │ │ ├── FreeMonoBold18pt7b.h │ │ ├── FreeMonoBold24pt7b.h │ │ ├── FreeMonoBold9pt7b.h │ │ ├── FreeMonoBoldOblique12pt7b.h │ │ ├── FreeMonoBoldOblique18pt7b.h │ │ ├── FreeMonoBoldOblique24pt7b.h │ │ ├── FreeMonoBoldOblique9pt7b.h │ │ ├── FreeMonoOblique12pt7b.h │ │ ├── FreeMonoOblique18pt7b.h │ │ ├── FreeMonoOblique24pt7b.h │ │ ├── FreeMonoOblique9pt7b.h │ │ ├── FreeSans12pt7b.h │ │ ├── FreeSans18pt7b.h │ │ ├── FreeSans24pt7b.h │ │ ├── FreeSans9pt7b.h │ │ ├── FreeSansBold12pt7b.h │ │ ├── FreeSansBold18pt7b.h │ │ ├── FreeSansBold24pt7b.h │ │ ├── FreeSansBold9pt7b.h │ │ ├── FreeSansBoldOblique12pt7b.h │ │ ├── FreeSansBoldOblique18pt7b.h │ │ ├── FreeSansBoldOblique24pt7b.h │ │ ├── FreeSansBoldOblique9pt7b.h │ │ ├── FreeSansOblique12pt7b.h │ │ ├── FreeSansOblique18pt7b.h │ │ ├── FreeSansOblique24pt7b.h │ │ ├── FreeSansOblique9pt7b.h │ │ ├── FreeSerif12pt7b.h │ │ ├── FreeSerif18pt7b.h │ │ ├── FreeSerif24pt7b.h │ │ ├── FreeSerif9pt7b.h │ │ ├── FreeSerifBold12pt7b.h │ │ ├── FreeSerifBold18pt7b.h │ │ ├── FreeSerifBold24pt7b.h │ │ ├── FreeSerifBold9pt7b.h │ │ ├── FreeSerifBoldItalic12pt7b.h │ │ ├── FreeSerifBoldItalic18pt7b.h │ │ ├── FreeSerifBoldItalic24pt7b.h │ │ ├── FreeSerifBoldItalic9pt7b.h │ │ ├── FreeSerifItalic12pt7b.h │ │ ├── FreeSerifItalic18pt7b.h │ │ ├── FreeSerifItalic24pt7b.h │ │ ├── FreeSerifItalic9pt7b.h │ │ ├── Org_01.h │ │ ├── Picopixel.h │ │ ├── Tiny3x3a2pt7b.h │ │ └── TomThumb.h │ ├── README.md │ ├── examples │ │ └── mock_ili9341 │ │ │ └── mock_ili9341.ino │ ├── fontconvert │ │ ├── Makefile │ │ ├── fontconvert.c │ │ ├── fontconvert_win.md │ │ └── makefonts.sh │ ├── gfxfont.h │ ├── glcdfont.c │ ├── library.properties │ └── license.txt ├── Adafruit_SSD1306 │ ├── .github │ │ ├── ISSUE_TEMPLATE.md │ │ └── PULL_REQUEST_TEMPLATE.md │ ├── .gitignore │ ├── .travis.yml │ ├── Adafruit_SSD1306.cpp │ ├── Adafruit_SSD1306.h │ ├── README.md │ ├── examples │ │ ├── OLED_featherwing │ │ │ └── OLED_featherwing.ino │ │ ├── ssd1306_128x32_i2c │ │ │ └── ssd1306_128x32_i2c.ino │ │ ├── ssd1306_128x32_spi │ │ │ └── ssd1306_128x32_spi.ino │ │ ├── ssd1306_128x64_i2c │ │ │ └── ssd1306_128x64_i2c.ino │ │ └── ssd1306_128x64_spi │ │ │ └── ssd1306_128x64_spi.ino │ ├── library.properties │ ├── license.txt │ ├── splash.h │ ├── ssd1306_i2c_driver.cpp │ ├── ssd1306_i2c_driver.h │ ├── ssd1306_spi_driver.cpp │ ├── ssd1306_spi_driver.h │ ├── ssd1306_sw_spi_driver.cpp │ └── ssd1306_sw_spi_driver.h ├── CMakeLists.txt ├── FreeRTOS │ ├── Arduino_FreeRTOS.c │ ├── Arduino_FreeRTOS.h │ ├── FreeRTOS.h │ ├── FreeRTOSConfig.h │ ├── StackMacros.h │ ├── croutine.c │ ├── croutine.h │ ├── deprecated_definitions.h │ ├── event_groups.c │ ├── event_groups.h │ ├── heap_1.c │ ├── list.c │ ├── list.h │ ├── mpu_prototypes.h │ ├── mpu_wrappers.h │ ├── port.c │ ├── portable.h │ ├── portmacro.h │ ├── projdefs.h │ ├── queue.c │ ├── queue.h │ ├── readme.txt │ ├── semphr.h │ ├── stdint.readme │ ├── task.h │ ├── tasks.c │ ├── timers.c │ └── timers.h ├── HAL │ ├── CMSIS │ │ ├── arm_common_tables.h │ │ ├── arm_const_structs.h │ │ ├── arm_math.h │ │ ├── cmsis_armcc.h │ │ ├── cmsis_armcc_V6.h │ │ ├── cmsis_gcc.h │ │ ├── core_cm0.h │ │ ├── core_cm0plus.h │ │ ├── core_cm3.h │ │ ├── core_cm4.h │ │ ├── core_cm7.h │ │ ├── core_cmFunc.h │ │ ├── core_cmInstr.h │ │ ├── core_cmSimd.h │ │ ├── core_sc000.h │ │ └── core_sc300.h │ └── STM32F1 │ │ ├── CMSIS_Inc │ │ ├── stm32f103xe.h │ │ ├── stm32f1xx.h │ │ └── system_stm32f1xx.h │ │ ├── CMSIS_Src │ │ └── startup_stm32f103xe.s │ │ ├── HAL_Inc │ │ ├── Legacy │ │ │ ├── stm32_hal_legacy.h │ │ │ ├── stm32f1xx_hal_can_ex_legacy.h │ │ │ └── stm32f1xx_hal_can_legacy.h │ │ ├── stm32_assert_template.h │ │ ├── stm32f1xx_hal.h │ │ ├── stm32f1xx_hal_adc.h │ │ ├── stm32f1xx_hal_adc_ex.h │ │ ├── stm32f1xx_hal_can.h │ │ ├── stm32f1xx_hal_can_ex.h │ │ ├── stm32f1xx_hal_cec.h │ │ ├── stm32f1xx_hal_conf.h │ │ ├── stm32f1xx_hal_conf_template.h │ │ ├── stm32f1xx_hal_cortex.h │ │ ├── stm32f1xx_hal_crc.h │ │ ├── stm32f1xx_hal_dac.h │ │ ├── stm32f1xx_hal_dac_ex.h │ │ ├── stm32f1xx_hal_def.h │ │ ├── stm32f1xx_hal_dma.h │ │ ├── stm32f1xx_hal_dma_ex.h │ │ ├── stm32f1xx_hal_eth.h │ │ ├── stm32f1xx_hal_flash.h │ │ ├── stm32f1xx_hal_flash_ex.h │ │ ├── stm32f1xx_hal_gpio.h │ │ ├── stm32f1xx_hal_gpio_ex.h │ │ ├── stm32f1xx_hal_hcd.h │ │ ├── stm32f1xx_hal_i2c.h │ │ ├── stm32f1xx_hal_i2s.h │ │ ├── stm32f1xx_hal_irda.h │ │ ├── stm32f1xx_hal_iwdg.h │ │ ├── stm32f1xx_hal_mmc.h │ │ ├── stm32f1xx_hal_nand.h │ │ ├── stm32f1xx_hal_nor.h │ │ ├── stm32f1xx_hal_pccard.h │ │ ├── stm32f1xx_hal_pcd.h │ │ ├── stm32f1xx_hal_pcd_ex.h │ │ ├── stm32f1xx_hal_pwr.h │ │ ├── stm32f1xx_hal_rcc.h │ │ ├── stm32f1xx_hal_rcc_ex.h │ │ ├── stm32f1xx_hal_rtc.h │ │ ├── stm32f1xx_hal_rtc_ex.h │ │ ├── stm32f1xx_hal_sd.h │ │ ├── stm32f1xx_hal_smartcard.h │ │ ├── stm32f1xx_hal_spi.h │ │ ├── stm32f1xx_hal_sram.h │ │ ├── stm32f1xx_hal_tim.h │ │ ├── stm32f1xx_hal_tim_ex.h │ │ ├── stm32f1xx_hal_uart.h │ │ ├── stm32f1xx_hal_usart.h │ │ ├── stm32f1xx_hal_wwdg.h │ │ ├── stm32f1xx_ll_adc.h │ │ ├── stm32f1xx_ll_bus.h │ │ ├── stm32f1xx_ll_cortex.h │ │ ├── stm32f1xx_ll_crc.h │ │ ├── stm32f1xx_ll_dac.h │ │ ├── stm32f1xx_ll_dma.h │ │ ├── stm32f1xx_ll_exti.h │ │ ├── stm32f1xx_ll_fsmc.h │ │ ├── stm32f1xx_ll_gpio.h │ │ ├── stm32f1xx_ll_i2c.h │ │ ├── stm32f1xx_ll_iwdg.h │ │ ├── stm32f1xx_ll_pwr.h │ │ ├── stm32f1xx_ll_rcc.h │ │ ├── stm32f1xx_ll_rtc.h │ │ ├── stm32f1xx_ll_sdmmc.h │ │ ├── stm32f1xx_ll_spi.h │ │ ├── stm32f1xx_ll_system.h │ │ ├── stm32f1xx_ll_tim.h │ │ ├── stm32f1xx_ll_usart.h │ │ ├── stm32f1xx_ll_usb.h │ │ ├── stm32f1xx_ll_utils.h │ │ └── stm32f1xx_ll_wwdg.h │ │ └── HAL_Src │ │ ├── Legacy │ │ └── stm32f1xx_hal_can.c │ │ ├── stm32f1xx_hal.c │ │ ├── stm32f1xx_hal_adc.c │ │ ├── stm32f1xx_hal_adc_ex.c │ │ ├── stm32f1xx_hal_can.c │ │ ├── stm32f1xx_hal_cec.c │ │ ├── stm32f1xx_hal_cortex.c │ │ ├── stm32f1xx_hal_crc.c │ │ ├── stm32f1xx_hal_dac.c │ │ ├── stm32f1xx_hal_dac_ex.c │ │ ├── stm32f1xx_hal_dma.c │ │ ├── stm32f1xx_hal_eth.c │ │ ├── stm32f1xx_hal_flash.c │ │ ├── stm32f1xx_hal_flash_ex.c │ │ ├── stm32f1xx_hal_gpio.c │ │ ├── stm32f1xx_hal_gpio_ex.c │ │ ├── stm32f1xx_hal_hcd.c │ │ ├── stm32f1xx_hal_i2c.c │ │ ├── stm32f1xx_hal_i2s.c │ │ ├── stm32f1xx_hal_irda.c │ │ ├── stm32f1xx_hal_iwdg.c │ │ ├── stm32f1xx_hal_mmc.c │ │ ├── stm32f1xx_hal_msp_template.c │ │ ├── stm32f1xx_hal_nand.c │ │ ├── stm32f1xx_hal_nor.c │ │ ├── stm32f1xx_hal_pccard.c │ │ ├── stm32f1xx_hal_pcd.c │ │ ├── stm32f1xx_hal_pcd_ex.c │ │ ├── stm32f1xx_hal_pwr.c │ │ ├── stm32f1xx_hal_rcc.c │ │ ├── stm32f1xx_hal_rcc_ex.c │ │ ├── stm32f1xx_hal_rtc.c │ │ ├── stm32f1xx_hal_rtc_ex.c │ │ ├── stm32f1xx_hal_sd.c │ │ ├── stm32f1xx_hal_smartcard.c │ │ ├── stm32f1xx_hal_spi.c │ │ ├── stm32f1xx_hal_spi_ex.c │ │ ├── stm32f1xx_hal_sram.c │ │ ├── stm32f1xx_hal_tim.c │ │ ├── stm32f1xx_hal_tim_ex.c │ │ ├── stm32f1xx_hal_timebase_rtc_alarm_template.c │ │ ├── stm32f1xx_hal_timebase_tim_template.c │ │ ├── stm32f1xx_hal_uart.c │ │ ├── stm32f1xx_hal_usart.c │ │ ├── stm32f1xx_hal_wwdg.c │ │ ├── stm32f1xx_ll_adc.c │ │ ├── stm32f1xx_ll_crc.c │ │ ├── stm32f1xx_ll_dac.c │ │ ├── stm32f1xx_ll_dma.c │ │ ├── stm32f1xx_ll_exti.c │ │ ├── stm32f1xx_ll_fsmc.c │ │ ├── stm32f1xx_ll_gpio.c │ │ ├── stm32f1xx_ll_i2c.c │ │ ├── stm32f1xx_ll_pwr.c │ │ ├── stm32f1xx_ll_rcc.c │ │ ├── stm32f1xx_ll_rtc.c │ │ ├── stm32f1xx_ll_sdmmc.c │ │ ├── stm32f1xx_ll_spi.c │ │ ├── stm32f1xx_ll_tim.c │ │ ├── stm32f1xx_ll_usart.c │ │ ├── stm32f1xx_ll_usb.c │ │ ├── stm32f1xx_ll_utils.c │ │ └── system_stm32f1xx.c ├── MiniArduino │ ├── Arduino.h │ ├── Print.cpp │ ├── Print.h │ ├── Printable.h │ ├── Stream.cpp │ ├── Stream.h │ ├── WString.cpp │ ├── WString.h │ ├── abi.cpp │ ├── avr │ │ └── pgmspace.h │ ├── bit_constants.h │ └── stm32 │ │ ├── stm32_clock.h │ │ └── stm32_def.h ├── NeoGPS │ ├── CosaCompat.h │ ├── DMS.cpp │ ├── DMS.h │ ├── GPSTime.cpp │ ├── GPSTime.h │ ├── GPSfix.h │ ├── GPSfix_cfg.h │ ├── GPSport.h │ ├── Location.cpp │ ├── Location.h │ ├── NMEAGPS.cpp │ ├── NMEAGPS.h │ ├── NMEAGPS_cfg.h │ ├── NeoGPS_cfg.h │ ├── NeoTime.cpp │ ├── NeoTime.h │ ├── Streamers.cpp │ ├── Streamers.h │ └── ublox │ │ ├── ubxGPS.cpp │ │ ├── ubxGPS.h │ │ ├── ubxNMEA.cpp │ │ ├── ubxNMEA.h │ │ ├── ubx_cfg.h │ │ ├── ubxmsg.cpp │ │ └── ubxmsg.h ├── SdFat │ ├── BlockDriver.h │ ├── FatLib │ │ ├── ArduinoFiles.h │ │ ├── ArduinoStream.h │ │ ├── BaseBlockDriver.h │ │ ├── FatApiConstants.h │ │ ├── FatFile.cpp │ │ ├── FatFile.h │ │ ├── FatFileLFN.cpp │ │ ├── FatFilePrint.cpp │ │ ├── FatFileSFN.cpp │ │ ├── FatFileSystem.h │ │ ├── FatLib.h │ │ ├── FatLibConfig.h │ │ ├── FatStructs.h │ │ ├── FatVolume.cpp │ │ ├── FatVolume.h │ │ ├── FmtNumber.cpp │ │ ├── FmtNumber.h │ │ ├── StdioStream.cpp │ │ ├── StdioStream.h │ │ ├── bufstream.h │ │ ├── fstream.cpp │ │ ├── fstream.h │ │ ├── ios.h │ │ ├── iostream.h │ │ ├── istream.cpp │ │ ├── istream.h │ │ ├── ostream.cpp │ │ └── ostream.h │ ├── FreeStack.h │ ├── MinimumSerial.cpp │ ├── MinimumSerial.h │ ├── SdCard │ │ ├── SdInfo.h │ │ ├── SdSpiCard.cpp │ │ ├── SdSpiCard.h │ │ ├── SdSpiCardEX.cpp │ │ ├── SdioCard.h │ │ ├── SdioCardEX.cpp │ │ └── SdioTeensy.cpp │ ├── SdFat.h │ ├── SdFatConfig.h │ ├── SpiDriver │ │ ├── DigitalPin.h │ │ ├── SdSpiBaseDriver.h │ │ ├── SdSpiDriver.h │ │ ├── SdSpiESP8266.cpp │ │ ├── SdSpiSAM3X.cpp │ │ ├── SdSpiSTM32F1.cpp │ │ ├── SdSpiTeensy3.cpp │ │ ├── SoftSPI.h │ │ └── boards │ │ │ ├── AvrDevelopersGpioPinMap.h │ │ │ ├── BobuinoGpioPinMap.h │ │ │ ├── GpioPinMap.h │ │ │ ├── LeonardoGpioPinMap.h │ │ │ ├── MegaGpioPinMap.h │ │ │ ├── SleepingBeautyGpioPinMap.h │ │ │ ├── Standard1284GpioPinMap.h │ │ │ ├── Teensy2GpioPinMap.h │ │ │ ├── Teensy2ppGpioPinMap.h │ │ │ └── UnoGpioPinMap.h │ └── SysCall.h └── USB │ ├── CDC │ ├── usbd_cdc.c │ ├── usbd_cdc.h │ ├── usbd_cdc_if.c │ └── usbd_cdc_if.h │ ├── Core │ ├── usbd_conf.c │ ├── usbd_conf.h │ ├── usbd_core.c │ ├── usbd_core.h │ ├── usbd_ctlreq.c │ ├── usbd_ctlreq.h │ ├── usbd_def.h │ ├── usbd_desc.c │ ├── usbd_desc.h │ ├── usbd_ioreq.c │ └── usbd_ioreq.h │ ├── MSC │ ├── usbd_msc.c │ ├── usbd_msc.h │ ├── usbd_msc_bot.c │ ├── usbd_msc_bot.h │ ├── usbd_msc_data.c │ ├── usbd_msc_data.h │ ├── usbd_msc_scsi.c │ └── usbd_msc_scsi.h │ └── MSC_CDC │ ├── usbd_msc_cdc.c │ └── usbd_msc_cdc.h ├── README.md ├── Scripts └── dump_firmware.py ├── Src ├── 8x12Font.cpp ├── 8x12Font.h ├── BoardInit.cpp ├── BoardInit.h ├── ButtonsThread.cpp ├── ButtonsThread.h ├── CMakeLists.txt ├── FontTest.cpp ├── FontTest.h ├── FreeRTOSHelpers.h ├── GPS │ ├── GPSDataModel.cpp │ ├── GPSDataModel.h │ ├── GPSOdometer.cpp │ ├── GPSOdometer.h │ ├── GPSSatellitesData.cpp │ ├── GPSSatellitesData.h │ ├── GPSThread.cpp │ └── GPSThread.h ├── GPSLogger.cpp ├── IdleThread.cpp ├── IdleThread.h ├── LEDThread.cpp ├── LEDThread.h ├── PrintUtils.cpp ├── PrintUtils.h ├── SDThread.cpp ├── SDThread.h ├── Screens │ ├── AltitudeScreen.cpp │ ├── AltitudeScreen.h │ ├── CurrentPositionScreen.cpp │ ├── CurrentPositionScreen.h │ ├── CurrentTimeScreen.cpp │ ├── CurrentTimeScreen.h │ ├── DebugScreen.cpp │ ├── DebugScreen.h │ ├── MemDumpScreen.cpp │ ├── MemDumpScreen.h │ ├── OdometerActionScreen.cpp │ ├── OdometerActionScreen.h │ ├── OdometerScreen.cpp │ ├── OdometerScreen.h │ ├── ParentScreen.cpp │ ├── ParentScreen.h │ ├── SPIDisplayDriver.cpp │ ├── SPIDisplayDriver.h │ ├── SatellitesScreen.cpp │ ├── SatellitesScreen.h │ ├── Screen.cpp │ ├── Screen.h │ ├── ScreenManager.cpp │ ├── ScreenManager.h │ ├── SelectorScreen.cpp │ ├── SelectorScreen.h │ ├── SettingsGroupScreen.cpp │ ├── SettingsGroupScreen.h │ ├── SpeedScreen.cpp │ ├── SpeedScreen.h │ ├── TimeZoneScreen.cpp │ └── TimeZoneScreen.h ├── SdFatSPIDriver.cpp ├── SdFatSPIDriver.h ├── SdMscDriver.cpp ├── SdMscDriver.h ├── SerialDebugLogger.cpp ├── SerialDebugLogger.h ├── Thread.h ├── TimeFont.cpp ├── TimeFont.h ├── USBDebugLogger.cpp └── USBDebugLogger.h ├── Test ├── FloatPrinterTest.cpp └── PrintfTest.cpp └── cmake ├── README.md ├── gcc_stm32.cmake ├── gcc_stm32f1.cmake └── stm32_linker.cmake /.gitattributes: -------------------------------------------------------------------------------- 1 | *.png filter=lfs diff=lfs merge=lfs -text 2 | *.pdf filter=lfs diff=lfs merge=lfs -text 3 | *.gif filter=lfs diff=lfs merge=lfs -text 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | Src/__vm 2 | Src/Debug 3 | Src/Release 4 | Src/.vs 5 | Build 6 | .metadata 7 | CMakeLists.txt.user* -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Always build in release as it uses -Os 2 | SET(CMAKE_BUILD_TYPE Release) 3 | 4 | # Handy path variables used in this script and passed to submodules 5 | SET(GPSLOGGER_LIBS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Libs) 6 | 7 | # All compiler related stuff is defined in the toolchain file 8 | SET(STM32_CHIP "STM32F103RC") 9 | 10 | # Flash offset due to bootloader 11 | SET(VECT_TAB_ADDR "0x2000") 12 | SET(STM32_FLASH_ORIGIN "0x08002000") 13 | 14 | # Load the toolchain file that uses vars above 15 | SET(CMAKE_TOOLCHAIN_FILE cmake/gcc_stm32.cmake) 16 | 17 | 18 | # Project definition 19 | PROJECT(GPSLogger) 20 | 21 | # Misc stuff 22 | CMAKE_MINIMUM_REQUIRED(VERSION 2.8) 23 | ENABLE_LANGUAGE(ASM) 24 | 25 | # Project wide definitions 26 | ADD_DEFINITIONS( 27 | -DSTM32F1 28 | -DSTM32F103RC 29 | -DSTM32F103xE # That is correct, all chips (F103xC, F103xD, and F103xE) have code under this define 30 | # -DUSE_USB_COMPOSITE 31 | # -DUSE_USB_MSC 32 | -DF_CPU=72000000L 33 | -DARDUINO=10801 34 | ) 35 | 36 | # Project wide include directories 37 | INCLUDE_DIRECTORIES( 38 | # Arduino layer (MiniArduino) 39 | ${GPSLOGGER_LIBS_DIR}/MiniArduino 40 | 41 | # HAL and CMSIS 42 | ${GPSLOGGER_LIBS_DIR}/HAL/CMSIS 43 | ${GPSLOGGER_LIBS_DIR}/HAL/STM32F1/CMSIS_Inc 44 | ${GPSLOGGER_LIBS_DIR}/HAL/STM32F1/HAL_Inc 45 | ) 46 | 47 | ADD_SUBDIRECTORY(Libs) 48 | ADD_SUBDIRECTORY(Src) 49 | 50 | -------------------------------------------------------------------------------- /Docs/Bluetooth_HM-13_en.pdf: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:2990d69575a4564cd2eb6835dfaa9742f69fd6ab105ce752baa65fa3f1e18b5d 3 | size 221299 4 | -------------------------------------------------------------------------------- /Docs/NEO-M8-FW3_DataSheet_(UBX-15031086).pdf: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:8b7e996f76ba0a70eed1999101caa935a0bb8b4da353269e070d5d0ef09dd373 3 | size 931409 4 | -------------------------------------------------------------------------------- /Docs/NEO-M8_DataSheet_(UBX-13003366).pdf: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:8673675895b30adeb22a85050b65fc3c9a0581a340699c9e54ff83ed11705829 3 | size 1311368 4 | -------------------------------------------------------------------------------- /Docs/PT1502.pdf: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:7db44123738a34ae06c9df589b8ca42494c3f58453a1bf23840002bea57d3dfb 3 | size 2225475 4 | -------------------------------------------------------------------------------- /Docs/UBLOX_NMEA_Example.txt: -------------------------------------------------------------------------------- 1 | $GNRMC,201224.00,A,2705.91250,N,03349.90190,E,1.532,,130317,,,A*68 2 | $GNVTG,,T,,M,1.532,N,2.836,K,A*37 3 | $GNGGA,201224.00,2705.91250,N,03349.90190,E,1,06,2.90,23.4,M,11.7,M,,*79 4 | $GNGSA,A,3,10,12,25,20,18,,,,,,,,3.80,2.90,2.47*13 5 | $GNGSA,A,3,65,,,,,,,,,,,,3.80,2.90,2.47*1E 6 | $GPGSV,2,1,08,10,06,197,18,12,14,142,26,15,04,120,11,16,04,322,*75 7 | $GPGSV,2,2,08,18,33,181,17,20,54,086,22,25,55,149,19,31,29,258,*7E 8 | $GLGSV,2,1,08,65,11,163,26,71,24,059,19,72,32,117,09,76,33,199,15*67 9 | $GLGSV,2,2,08,77,50,279,,78,12,330,,87,41,341,,88,19,289,*6F 10 | $GNGLL,2705.91250,N,03349.90190,E,201224.00,A,A*73 11 | -------------------------------------------------------------------------------- /Docs/bluepill-pinout.gif: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:8f1ca4e9d4de4e398291f5f0fb0906e5fccc7227b2e26b3032aa001db304849c 3 | size 145549 4 | -------------------------------------------------------------------------------- /Docs/bluepill-schematic.pdf: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:cb8520d7f1b58d4e91a6c79141cc1e422036ab91c20a7c60839bd1d4d6dd8ad0 3 | size 151372 4 | -------------------------------------------------------------------------------- /Docs/bluepill-schematics.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:957e5313f9b0dac9f5cae8a262281dbb48fe028d67eaf7adab00760d725407d5 3 | size 219213 4 | -------------------------------------------------------------------------------- /Docs/ina219.pdf: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:92e92c35f2709ec50c222bc871e1e2ad56fdb09b354f0d7cafc072ddf42f1184 3 | size 1190353 4 | -------------------------------------------------------------------------------- /Docs/maplemini.pdf: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:622fc3ca48c9441a89df05e4b4e1397edb6b43d279a4ed2a21cde5b1d642d664 3 | size 24883 4 | -------------------------------------------------------------------------------- /Docs/stm32f103_reference_manual.pdf: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:b41dd34d04c0c8856f515a794cdf5288bfc8bc82fb1c70c2e68b48883e97bc47 3 | size 13340668 4 | -------------------------------------------------------------------------------- /Docs/stm32f103xC_datasheet.pdf: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:c9b21d3e41aa42a080cb0b2d8a8a687e6646395d06dc0422b664d4465c34a56a 3 | size 3225510 4 | -------------------------------------------------------------------------------- /Docs/stm32f103xb_datasheet.pdf: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:4741c03c5793745c1709ab48237ea23d204c4fc2ca735ceafa03367f32960917 3 | size 2006428 4 | -------------------------------------------------------------------------------- /Docs/stm32f103xb_pinout.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:2662075c94b850678d7b421051d3431b2d19aad6201e468d04a9cb5d95d86814 3 | size 798023 4 | -------------------------------------------------------------------------------- /Docs/stm32f407_datasheet.pdf: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:9d863ca0c078917fe6bfa86683a5b7001c5379a23bbceb60a01830675a552e34 3 | size 6126047 4 | -------------------------------------------------------------------------------- /Docs/stm32f407_reference_manual.pdf: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:6b0e1d3bd9dfd0af230f65195652909dda687d784facae3f5f3d592e2c130495 3 | size 21928652 4 | -------------------------------------------------------------------------------- /Docs/u-blox8-M8_ReceiverDescrProtSpec_(UBX-13003221)_Public.pdf: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:5068ee734c744c6441170a4c54bee60072538c6e82bc73329987dd14794bd0d0 3 | size 7482014 4 | -------------------------------------------------------------------------------- /Fonts/22x16 Numbers.pdn: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/grafalex82/GPSLogger/4c53cab01d60977f78a8cb53cc879c3dcd655230/Fonts/22x16 Numbers.pdn -------------------------------------------------------------------------------- /Fonts/22x16 Numbers.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:c88e29723a8f2a1e6d65e6812f4d3a1a8db8221ca93d59a1dc0c2ea1769f034c 3 | size 1262 4 | -------------------------------------------------------------------------------- /Fonts/8x12_Numbers.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:d314259fc1bd110112a913cbbd74f7900414ac9769825049087250c8c0885406 3 | size 432 4 | -------------------------------------------------------------------------------- /Fonts/FontGenerate.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | import png 4 | 5 | def parse_symbol(pixels, x_offset, y_offset, sym_width, sym_height): 6 | print "Parsing symbol at %d:%d" % (x_offset, y_offset) 7 | symb = [] 8 | for y in range(sym_height): 9 | line = [] 10 | for x in range(sym_width): 11 | pixel = pixels[y+y_offset][(x+x_offset)*4] # Greyscale is not supported yet. Assuming 4 bytes per pixel 12 | line.append(1 if (pixel == 0) else 0) 13 | symb.append(line) 14 | 15 | return symb 16 | 17 | def strip_symbol(symb): 18 | #TODO: Perhaps this all could be easier with numpy 19 | 20 | y_padding = 0 21 | x_padding = 0 22 | 23 | # Strip top line 24 | while True: 25 | if 1 in symb[0]: 26 | break 27 | else: 28 | symb = symb[1:] 29 | y_padding += 1 30 | 31 | 32 | # Strip bottom line 33 | while True: 34 | if 1 in symb[-1]: 35 | break 36 | else: 37 | symb = symb[:-1] 38 | 39 | # Strip left column 40 | while True: 41 | if 1 in [symb[y][0] for y in range(len(symb))]: 42 | break 43 | else: 44 | x_padding += 1 45 | for y in range(len(symb)): 46 | symb[y] = symb[y][1:] 47 | 48 | # Strip right column 49 | while True: 50 | if 1 in [symb[y][-1] for y in range(len(symb))]: 51 | break 52 | else: 53 | for y in range(len(symb)): 54 | symb[y] = symb[y][:-1] 55 | 56 | # for l in symb: 57 | # print l 58 | 59 | return symb, x_padding, y_padding 60 | 61 | 62 | def print_bitmap(symb, idx): 63 | bitmap = "" 64 | b = 0 65 | bits = 0 66 | 67 | for line in symb: 68 | for p in line: 69 | b = b << 1 70 | if p: 71 | b += 1 72 | 73 | # Store the bit 74 | bits += 1 75 | if bits == 8: 76 | bitmap += "0x" + format(b, "02x") + ", " 77 | b = 0 78 | bits = 0 79 | 80 | if bits != 0: 81 | b = b << (8-bits) 82 | bitmap += "0x" + format(b, "02x") + ',' 83 | 84 | print "%s //0x%s '%c'" % (bitmap, format(idx, "02x"), chr(idx)) 85 | 86 | def print_glyph(symb, sym_width, sym_height, idx, offset): 87 | pixels = symb[0] 88 | x_padding = symb[1] 89 | y_padding = symb[2] 90 | 91 | print "%d, %d, %d, %d, %d, %d, //0x%s '%c'" % (offset, len(pixels[0]), len(pixels), sym_width, x_padding, y_padding-sym_height, format(idx, "02x"), chr(idx)) 92 | 93 | size = len(pixels) * len(pixels[0]) 94 | if size % 8 != 0: 95 | size += 8 - size % 8 96 | 97 | return size / 8 98 | 99 | def main(): 100 | if len(sys.argv) < 4: 101 | print "Usage: FontGenerate.py " 102 | exit(1) 103 | 104 | filename = sys.argv[1] 105 | sym_width = int(sys.argv[2]) 106 | sym_height = int(sys.argv[3]) 107 | base_idx = int(sys.argv[4]) 108 | 109 | print "Reading", filename 110 | 111 | r=png.Reader(filename=filename) 112 | pic_width, pic_height, pixels_obj, pic_params = r.read() 113 | pixels = list(pixels_obj) 114 | 115 | print pic_params 116 | print pixels[0] 117 | 118 | symbols = [] 119 | for y_offset in [sym_height*offset for offset in range(pic_height/sym_height)]: 120 | for x_offset in [sym_width*offset for offset in range(pic_width/sym_width)]: 121 | symb = parse_symbol(pixels, x_offset, y_offset, sym_width, sym_height) 122 | symbols.append(strip_symbol(symb)) 123 | 124 | idx = base_idx 125 | for symb in symbols: 126 | print_bitmap(symb[0], idx) 127 | idx += 1 128 | 129 | idx = base_idx 130 | offset = 0 131 | for symb in symbols: 132 | offset += print_glyph(symb, sym_width, sym_height, idx, offset) 133 | idx += 1 134 | 135 | if __name__ == "__main__": 136 | main() -------------------------------------------------------------------------------- /Fonts/Xwindows_8x12.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:705689224a26d10bc9e8336a61666bb91c631941611e4f4f2e902dd1d74c15e4 3 | size 2230 4 | -------------------------------------------------------------------------------- /Libs/AdafruitGFX/.gitignore: -------------------------------------------------------------------------------- 1 | default.vim 2 | fontconvert/fontconvert 3 | # Our handy .gitignore for automation ease 4 | Doxyfile* 5 | doxygen_sqlite3.db 6 | html -------------------------------------------------------------------------------- /Libs/AdafruitGFX/.travis.yml: -------------------------------------------------------------------------------- 1 | language: c 2 | sudo: false 3 | cache: 4 | directories: 5 | - ~/arduino_ide 6 | - ~/.arduino15/packages/ 7 | git: 8 | depth: false 9 | quiet: true 10 | env: 11 | global: 12 | - PRETTYNAME="Adafruit GFX Library" 13 | 14 | before_install: 15 | - source <(curl -SLs https://raw.githubusercontent.com/adafruit/travis-ci-arduino/master/install.sh) 16 | 17 | install: 18 | - arduino --install-library "Adafruit ILI9341" 19 | 20 | script: 21 | - build_main_platforms 22 | 23 | # Generate and deploy documentation 24 | after_success: 25 | - source <(curl -SLs https://raw.githubusercontent.com/adafruit/travis-ci-arduino/master/library_check.sh) 26 | - source <(curl -SLs https://raw.githubusercontent.com/adafruit/travis-ci-arduino/master/doxy_gen_and_deploy.sh) 27 | -------------------------------------------------------------------------------- /Libs/AdafruitGFX/Adafruit_SPITFT_Macros.h: -------------------------------------------------------------------------------- 1 | // THIS FILE INTENTIONALLY LEFT BLANK. 2 | 3 | // Macros previously #defined here have been made into (mostly) inline 4 | // functions in the Adafruit_SPITFT class. Other libraries might still 5 | // contain code trying to #include this header file, so until everything's 6 | // updated this file still exists (but doing nothing) to avoid trouble. 7 | -------------------------------------------------------------------------------- /Libs/AdafruitGFX/README.md: -------------------------------------------------------------------------------- 1 | # Adafruit GFX Library [![Build Status](https://travis-ci.com/adafruit/Adafruit-GFX-Library.svg?branch=master)](https://travis-ci.com/adafruit/Adafruit-GFX-Library) 2 | 3 | This is the core graphics library for all our displays, providing a common set of graphics primitives (points, lines, circles, etc.). It needs to be paired with a hardware-specific library for each display device we carry (to handle the lower-level functions). 4 | 5 | Adafruit invests time and resources providing this open source code, please support Adafruit and open-source hardware by purchasing products from Adafruit! 6 | 7 | Written by Limor Fried/Ladyada for Adafruit Industries. 8 | BSD license, check license.txt for more information. 9 | All text above must be included in any redistribution. 10 | 11 | Recent Arduino IDE releases include the Library Manager for easy installation. Otherwise, to download, click the DOWNLOAD ZIP button, uncompress and rename the uncompressed folder Adafruit_GFX. Confirm that the Adafruit_GFX folder contains Adafruit_GFX.cpp and Adafruit_GFX.h. Place the Adafruit_GFX library folder your ArduinoSketchFolder/Libraries/ folder. You may need to create the Libraries subfolder if its your first library. Restart the IDE. 12 | 13 | # Useful Resources 14 | 15 | - Image2Code: This is a handy Java GUI utility to convert a BMP file into the array code necessary to display the image with the drawBitmap function. Check out the code at ehubin's GitHub repository: https://github.com/ehubin/Adafruit-GFX-Library/tree/master/Img2Code 16 | 17 | - drawXBitmap function: You can use the GIMP photo editor to save a .xbm file and use the array saved in the file to draw a bitmap with the drawXBitmap function. See the pull request here for more details: https://github.com/adafruit/Adafruit-GFX-Library/pull/31 18 | 19 | - 'Fonts' folder contains bitmap fonts for use with recent (1.1 and later) Adafruit_GFX. To use a font in your Arduino sketch, \#include the corresponding .h file and pass address of GFXfont struct to setFont(). Pass NULL to revert to 'classic' fixed-space bitmap font. 20 | 21 | - 'fontconvert' folder contains a command-line tool for converting TTF fonts to Adafruit_GFX header format. 22 | 23 | --- 24 | 25 | ### Roadmap 26 | 27 | The PRIME DIRECTIVE is to maintain backward compatibility with existing Arduino sketches -- many are hosted elsewhere and don't track changes here, some are in print and can never be changed! This "little" library has grown organically over time and sometimes we paint ourselves into a design corner and just have to live with it or add ungainly workarounds. 28 | 29 | Highly unlikely to merge any changes for additional or incompatible font formats (see Prime Directive above). There are already two formats and the code is quite bloaty there as it is (this also creates liabilities for tools and documentation). If you *must* have a more sophisticated font format, consider creating a fork with the features required for your project. For similar reasons, also unlikely to add any more bitmap formats, it's getting messy. 30 | 31 | Please don't reformat code for the sake of reformatting code. The resulting large "visual diff" makes it impossible to untangle actual bug fixes from merely rearranged lines. 32 | -------------------------------------------------------------------------------- /Libs/AdafruitGFX/fontconvert/Makefile: -------------------------------------------------------------------------------- 1 | all: fontconvert 2 | 3 | CC = gcc 4 | CFLAGS = -Wall -I/usr/local/include/freetype2 -I/usr/include/freetype2 -I/usr/include 5 | LIBS = -lfreetype 6 | 7 | fontconvert: fontconvert.c 8 | $(CC) $(CFLAGS) $< $(LIBS) -o $@ 9 | strip $@ 10 | 11 | clean: 12 | rm -f fontconvert 13 | -------------------------------------------------------------------------------- /Libs/AdafruitGFX/fontconvert/makefonts.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Ugly little Bash script, generates a set of .h files for GFX using 4 | # GNU FreeFont sources. There are three fonts: 'Mono' (Courier-like), 5 | # 'Sans' (Helvetica-like) and 'Serif' (Times-like); four styles: regular, 6 | # bold, oblique or italic, and bold+oblique or bold+italic; and four 7 | # sizes: 9, 12, 18 and 24 point. No real error checking or anything, 8 | # this just powers through all the combinations, calling the fontconvert 9 | # utility and redirecting the output to a .h file for each combo. 10 | 11 | # Adafruit_GFX repository does not include the source outline fonts 12 | # (huge zipfile, different license) but they're easily acquired: 13 | # http://savannah.gnu.org/projects/freefont/ 14 | 15 | convert=./fontconvert 16 | inpath=~/Desktop/freefont/ 17 | outpath=../Fonts/ 18 | fonts=(FreeMono FreeSans FreeSerif) 19 | styles=("" Bold Italic BoldItalic Oblique BoldOblique) 20 | sizes=(9 12 18 24) 21 | 22 | for f in ${fonts[*]} 23 | do 24 | for index in ${!styles[*]} 25 | do 26 | st=${styles[$index]} 27 | for si in ${sizes[*]} 28 | do 29 | infile=$inpath$f$st".ttf" 30 | if [ -f $infile ] # Does source combination exist? 31 | then 32 | outfile=$outpath$f$st$si"pt7b.h" 33 | # printf "%s %s %s > %s\n" $convert $infile $si $outfile 34 | $convert $infile $si > $outfile 35 | fi 36 | done 37 | done 38 | done 39 | -------------------------------------------------------------------------------- /Libs/AdafruitGFX/gfxfont.h: -------------------------------------------------------------------------------- 1 | // Font structures for newer Adafruit_GFX (1.1 and later). 2 | // Example fonts are included in 'Fonts' directory. 3 | // To use a font in your Arduino sketch, #include the corresponding .h 4 | // file and pass address of GFXfont struct to setFont(). Pass NULL to 5 | // revert to 'classic' fixed-space bitmap font. 6 | 7 | #ifndef _GFXFONT_H_ 8 | #define _GFXFONT_H_ 9 | 10 | /// Font data stored PER GLYPH 11 | typedef struct { 12 | uint16_t bitmapOffset; ///< Pointer into GFXfont->bitmap 13 | uint8_t width; ///< Bitmap dimensions in pixels 14 | uint8_t height; ///< Bitmap dimensions in pixels 15 | uint8_t xAdvance; ///< Distance to advance cursor (x axis) 16 | int8_t xOffset; ///< X dist from cursor pos to UL corner 17 | int8_t yOffset; ///< Y dist from cursor pos to UL corner 18 | } GFXglyph; 19 | 20 | /// Data stored for FONT AS A WHOLE 21 | typedef struct { 22 | const uint8_t *bitmap; ///< Glyph bitmaps, concatenated 23 | const GFXglyph *glyph; ///< Glyph array 24 | uint8_t first; ///< ASCII extents (first char) 25 | uint8_t last; ///< ASCII extents (last char) 26 | uint8_t yAdvance; ///< Newline distance (y axis) 27 | } GFXfont; 28 | 29 | #endif // _GFXFONT_H_ 30 | -------------------------------------------------------------------------------- /Libs/AdafruitGFX/library.properties: -------------------------------------------------------------------------------- 1 | name=Adafruit GFX Library 2 | version=1.5.3 3 | author=Adafruit 4 | maintainer=Adafruit 5 | sentence=Adafruit GFX graphics core library, this is the 'core' class that all our other graphics libraries derive from. 6 | paragraph=Install this library in addition to the display library for your hardware. 7 | category=Display 8 | url=https://github.com/adafruit/Adafruit-GFX-Library 9 | architectures=* 10 | -------------------------------------------------------------------------------- /Libs/AdafruitGFX/license.txt: -------------------------------------------------------------------------------- 1 | Software License Agreement (BSD License) 2 | 3 | Copyright (c) 2012 Adafruit Industries. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | - Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | - Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | POSSIBILITY OF SUCH DAMAGE. 25 | -------------------------------------------------------------------------------- /Libs/Adafruit_SSD1306/.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | Thank you for opening an issue on an Adafruit Arduino library repository. To 2 | improve the speed of resolution please review the following guidelines and 3 | common troubleshooting steps below before creating the issue: 4 | 5 | - **Do not use GitHub issues for troubleshooting projects and issues.** Instead use 6 | the forums at http://forums.adafruit.com to ask questions and troubleshoot why 7 | something isn't working as expected. In many cases the problem is a common issue 8 | that you will more quickly receive help from the forum community. GitHub issues 9 | are meant for known defects in the code. If you don't know if there is a defect 10 | in the code then start with troubleshooting on the forum first. 11 | 12 | - **If following a tutorial or guide be sure you didn't miss a step.** Carefully 13 | check all of the steps and commands to run have been followed. Consult the 14 | forum if you're unsure or have questions about steps in a guide/tutorial. 15 | 16 | - **For Arduino projects check these very common issues to ensure they don't apply**: 17 | 18 | - For uploading sketches or communicating with the board make sure you're using 19 | a **USB data cable** and **not** a **USB charge-only cable**. It is sometimes 20 | very hard to tell the difference between a data and charge cable! Try using the 21 | cable with other devices or swapping to another cable to confirm it is not 22 | the problem. 23 | 24 | - **Be sure you are supplying adequate power to the board.** Check the specs of 25 | your board and plug in an external power supply. In many cases just 26 | plugging a board into your computer is not enough to power it and other 27 | peripherals. 28 | 29 | - **Double check all soldering joints and connections.** Flakey connections 30 | cause many mysterious problems. See the [guide to excellent soldering](https://learn.adafruit.com/adafruit-guide-excellent-soldering/tools) for examples of good solder joints. 31 | 32 | - **Ensure you are using an official Arduino or Adafruit board.** We can't 33 | guarantee a clone board will have the same functionality and work as expected 34 | with this code and don't support them. 35 | 36 | If you're sure this issue is a defect in the code and checked the steps above 37 | please fill in the following fields to provide enough troubleshooting information. 38 | You may delete the guideline and text above to just leave the following details: 39 | 40 | - Arduino board: **INSERT ARDUINO BOARD NAME/TYPE HERE** 41 | 42 | - Arduino IDE version (found in Arduino -> About Arduino menu): **INSERT ARDUINO 43 | VERSION HERE** 44 | 45 | - List the steps to reproduce the problem below (if possible attach a sketch or 46 | copy the sketch code in too): **LIST REPRO STEPS BELOW** 47 | -------------------------------------------------------------------------------- /Libs/Adafruit_SSD1306/.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | Thank you for creating a pull request to contribute to Adafruit's GitHub code! 2 | Before you open the request please review the following guidelines and tips to 3 | help it be more easily integrated: 4 | 5 | - **Describe the scope of your change--i.e. what the change does and what parts 6 | of the code were modified.** This will help us understand any risks of integrating 7 | the code. 8 | 9 | - **Describe any known limitations with your change.** For example if the change 10 | doesn't apply to a supported platform of the library please mention it. 11 | 12 | - **Please run any tests or examples that can exercise your modified code.** We 13 | strive to not break users of the code and running tests/examples helps with this 14 | process. 15 | 16 | Thank you again for contributing! We will try to test and integrate the change 17 | as soon as we can, but be aware we have many GitHub repositories to manage and 18 | can't immediately respond to every request. There is no need to bump or check in 19 | on a pull request (it will clutter the discussion of the request). 20 | 21 | Also don't be worried if the request is closed or not integrated--sometimes the 22 | priorities of Adafruit's GitHub code (education, ease of use) might not match the 23 | priorities of the pull request. Don't fret, the open source community thrives on 24 | forks and GitHub makes it easy to keep your changes in a forked repo. 25 | 26 | After reviewing the guidelines above you can delete this text from the pull request. 27 | -------------------------------------------------------------------------------- /Libs/Adafruit_SSD1306/.gitignore: -------------------------------------------------------------------------------- 1 | # Our handy .gitignore for automation ease 2 | Doxyfile* 3 | doxygen_sqlite3.db 4 | html 5 | -------------------------------------------------------------------------------- /Libs/Adafruit_SSD1306/.travis.yml: -------------------------------------------------------------------------------- 1 | language: c 2 | sudo: false 3 | cache: 4 | directories: 5 | - ~/arduino_ide 6 | - ~/.arduino15/packages/ 7 | git: 8 | depth: false 9 | quiet: true 10 | env: 11 | global: 12 | - ARDUINO_IDE_VERSION="1.8.5" 13 | - PRETTYNAME="Adafruit SSD1306" 14 | # Optional, will default to "$TRAVIS_BUILD_DIR/Doxyfile" 15 | # - DOXYFILE: $TRAVIS_BUILD_DIR/Doxyfile 16 | 17 | before_install: 18 | - source <(curl -SLs https://raw.githubusercontent.com/adafruit/travis-ci-arduino/master/install.sh) 19 | 20 | install: 21 | - arduino --install-library "Adafruit GFX Library" 22 | 23 | script: 24 | - build_main_platforms 25 | 26 | # Generate and deploy documentation 27 | after_success: 28 | - source <(curl -SLs https://raw.githubusercontent.com/adafruit/travis-ci-arduino/master/library_check.sh) 29 | - source <(curl -SLs https://raw.githubusercontent.com/adafruit/travis-ci-arduino/master/doxy_gen_and_deploy.sh) 30 | -------------------------------------------------------------------------------- /Libs/Adafruit_SSD1306/examples/OLED_featherwing/OLED_featherwing.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | SSD1306_I2C_Driver i2c_driver(0x3C); // Address 0x3C for 128x32 8 | Adafruit_SSD1306 display = Adafruit_SSD1306(128, 32, &i2c_driver); 9 | 10 | // OLED FeatherWing buttons map to different pins depending on board: 11 | #if defined(ESP8266) 12 | #define BUTTON_A 0 13 | #define BUTTON_B 16 14 | #define BUTTON_C 2 15 | #elif defined(ESP32) 16 | #define BUTTON_A 15 17 | #define BUTTON_B 32 18 | #define BUTTON_C 14 19 | #elif defined(ARDUINO_STM32_FEATHER) 20 | #define BUTTON_A PA15 21 | #define BUTTON_B PC7 22 | #define BUTTON_C PC5 23 | #elif defined(TEENSYDUINO) 24 | #define BUTTON_A 4 25 | #define BUTTON_B 3 26 | #define BUTTON_C 8 27 | #elif defined(ARDUINO_FEATHER52832) 28 | #define BUTTON_A 31 29 | #define BUTTON_B 30 30 | #define BUTTON_C 27 31 | #else // 32u4, M0, M4, nrf52840 and 328p 32 | #define BUTTON_A 9 33 | #define BUTTON_B 6 34 | #define BUTTON_C 5 35 | #endif 36 | 37 | void setup() { 38 | Serial.begin(9600); 39 | 40 | Serial.println("OLED FeatherWing test"); 41 | 42 | display.begin(); 43 | 44 | Serial.println("OLED begun"); 45 | 46 | // Show image buffer on the display hardware. 47 | // Since the buffer is intialized with an Adafruit splashscreen 48 | // internally, this will display the splashscreen. 49 | display.display(); 50 | delay(1000); 51 | 52 | // Clear the buffer. 53 | display.clearDisplay(); 54 | display.display(); 55 | 56 | Serial.println("IO test"); 57 | 58 | pinMode(BUTTON_A, INPUT_PULLUP); 59 | pinMode(BUTTON_B, INPUT_PULLUP); 60 | pinMode(BUTTON_C, INPUT_PULLUP); 61 | 62 | // text display tests 63 | display.setTextSize(1); 64 | display.setTextColor(WHITE); 65 | display.setCursor(0,0); 66 | display.print("Connecting to SSID\n'adafruit':"); 67 | display.print("connected!"); 68 | display.println("IP: 10.0.1.23"); 69 | display.println("Sending val #0"); 70 | display.setCursor(0,0); 71 | display.display(); // actually display all of the above 72 | } 73 | 74 | void loop() { 75 | if(!digitalRead(BUTTON_A)) display.print("A"); 76 | if(!digitalRead(BUTTON_B)) display.print("B"); 77 | if(!digitalRead(BUTTON_C)) display.print("C"); 78 | delay(10); 79 | yield(); 80 | display.display(); 81 | } 82 | -------------------------------------------------------------------------------- /Libs/Adafruit_SSD1306/library.properties: -------------------------------------------------------------------------------- 1 | name=Adafruit SSD1306 2 | version=1.2.9 3 | author=Adafruit 4 | maintainer=Adafruit 5 | sentence=SSD1306 oled driver library for monochrome 128x64 and 128x32 displays 6 | paragraph=SSD1306 oled driver library for monochrome 128x64 and 128x32 displays 7 | category=Display 8 | url=https://github.com/adafruit/Adafruit_SSD1306 9 | architectures=* 10 | -------------------------------------------------------------------------------- /Libs/Adafruit_SSD1306/license.txt: -------------------------------------------------------------------------------- 1 | Software License Agreement (BSD License) 2 | 3 | Copyright (c) 2012, Adafruit Industries 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 1. Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | 2. Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | 3. Neither the name of the copyright holders nor the 14 | names of its contributors may be used to endorse or promote products 15 | derived from this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY 18 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 21 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | -------------------------------------------------------------------------------- /Libs/Adafruit_SSD1306/ssd1306_i2c_driver.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #if defined(BUFFER_LENGTH) 4 | #define WIRE_MAX BUFFER_LENGTH ///< AVR or similar Wire lib 5 | #elif defined(SERIAL_BUFFER_SIZE) 6 | #define WIRE_MAX (SERIAL_BUFFER_SIZE-1) ///< Newer Wire uses RingBuffer 7 | #else 8 | #define WIRE_MAX 32 ///< Use common Arduino core default 9 | #endif 10 | 11 | #if ARDUINO >= 100 12 | #define WIRE_WRITE wire->write ///< Wire write function in recent Arduino lib 13 | #else 14 | #define WIRE_WRITE wire->send ///< Wire write function in older Arduino lib 15 | #endif 16 | 17 | #include "ssd1306_i2c_driver.h" 18 | 19 | SSD1306_I2C_Driver::SSD1306_I2C_Driver(int8_t addr, int8_t rst_pin, TwoWire *twi, 20 | bool periphBegin, uint32_t clkDuring, uint32_t clkAfter) 21 | : i2caddr(addr) 22 | , wire(twi) 23 | , needsInit(periphBegin) 24 | , resetPin(rst_pin) 25 | #if ARDUINO >= 157 26 | , wireClk(clkDuring) 27 | , restoreClk(clkAfter) 28 | #endif 29 | { 30 | } 31 | 32 | void SSD1306_I2C_Driver::begin() 33 | { 34 | // TwoWire begin() function might be already performed by the calling 35 | // function if it has unusual circumstances (e.g. TWI variants that 36 | // can accept different SDA/SCL pins, or if two SSD1306 instances 37 | // with different addresses -- only a single begin() is needed). 38 | if(needsInit) 39 | wire->begin(); 40 | 41 | // Reset SSD1306 if requested and reset pin specified in constructor 42 | if(resetPin >= 0) 43 | { 44 | pinMode( resetPin, OUTPUT); 45 | digitalWrite(resetPin, HIGH); 46 | delay(1); // VDD goes high at start, pause for 1 ms 47 | digitalWrite(resetPin, LOW); // Bring reset low 48 | delay(10); // Wait 10 ms 49 | digitalWrite(resetPin, HIGH); // Bring out of reset 50 | } 51 | } 52 | 53 | void SSD1306_I2C_Driver::startTransaction() 54 | { 55 | #if (ARDUINO >= 157) && !defined(ARDUINO_STM32_FEATHER) 56 | wire->setClock(wireClk); 57 | #endif 58 | } 59 | 60 | void SSD1306_I2C_Driver::sendCommand(uint8_t cmd) 61 | { 62 | wire->beginTransmission(i2caddr); 63 | WIRE_WRITE((uint8_t)0x00); // Co = 0, D/C = 0 64 | WIRE_WRITE(cmd); 65 | wire->endTransmission(); 66 | } 67 | 68 | void SSD1306_I2C_Driver::sendCommands(const uint8_t *cmds, size_t size) 69 | { 70 | wire->beginTransmission(i2caddr); 71 | WIRE_WRITE((uint8_t)0x00); // Co = 0, D/C = 0 72 | uint8_t bytesOut = 1; 73 | while(size--) { 74 | if(bytesOut >= WIRE_MAX) { 75 | wire->endTransmission(); 76 | wire->beginTransmission(i2caddr); 77 | WIRE_WRITE((uint8_t)0x00); // Co = 0, D/C = 0 78 | bytesOut = 1; 79 | } 80 | WIRE_WRITE(pgm_read_byte(cmds++)); 81 | bytesOut++; 82 | } 83 | wire->endTransmission(); 84 | } 85 | 86 | void SSD1306_I2C_Driver::sendData(const uint8_t * data, size_t size) 87 | { 88 | wire->beginTransmission(i2caddr); 89 | WIRE_WRITE((uint8_t)0x40); 90 | uint8_t bytesOut = 1; 91 | while(size--) { 92 | if(bytesOut >= WIRE_MAX) { 93 | wire->endTransmission(); 94 | wire->beginTransmission(i2caddr); 95 | WIRE_WRITE((uint8_t)0x40); 96 | bytesOut = 1; 97 | } 98 | WIRE_WRITE(*data++); 99 | bytesOut++; 100 | } 101 | wire->endTransmission(); 102 | } 103 | 104 | void SSD1306_I2C_Driver::endTransaction() 105 | { 106 | #if (ARDUINO >= 157) && !defined(ARDUINO_STM32_FEATHER) 107 | wire->setClock(restoreClk); 108 | #endif 109 | } 110 | -------------------------------------------------------------------------------- /Libs/Adafruit_SSD1306/ssd1306_spi_driver.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "ssd1306_spi_driver.h" 4 | 5 | #ifdef HAVE_PORTREG 6 | #define SSD1306_SELECT *csPort &= ~csPinMask; ///< Device select 7 | #define SSD1306_DESELECT *csPort |= csPinMask; ///< Device deselect 8 | #define SSD1306_MODE_COMMAND *dcPort &= ~dcPinMask; ///< Command mode 9 | #define SSD1306_MODE_DATA *dcPort |= dcPinMask; ///< Data mode 10 | #else 11 | #define SSD1306_SELECT digitalWrite(csPin, LOW); ///< Device select 12 | #define SSD1306_DESELECT digitalWrite(csPin, HIGH); ///< Device deselect 13 | #define SSD1306_MODE_COMMAND digitalWrite(dcPin, LOW); ///< Command mode 14 | #define SSD1306_MODE_DATA digitalWrite(dcPin, HIGH); ///< Data mode 15 | #endif 16 | 17 | 18 | SSD1306_SPI_Driver::SSD1306_SPI_Driver(int8_t dc_pin, int8_t cs_pin, int8_t rst_pin, SPIClass *spi, bool periphBegin, uint32_t bitrate) 19 | : dcPin(dc_pin) 20 | , csPin(cs_pin) 21 | , rstPin(rst_pin) 22 | , spi(spi) 23 | , needsInit(periphBegin) 24 | { 25 | #ifdef SPI_HAS_TRANSACTION 26 | spiSettings = SPISettings(bitrate, MSBFIRST, SPI_MODE0); 27 | #endif 28 | } 29 | 30 | void SSD1306_SPI_Driver::begin() 31 | { 32 | // set pins modes 33 | pinMode(dcPin, OUTPUT); // Set data/command pin as output 34 | pinMode(csPin, OUTPUT); // Same for chip select 35 | 36 | #ifdef HAVE_PORTREG 37 | dcPort = (PortReg *)portOutputRegister(digitalPinToPort(dcPin)); 38 | dcPinMask = digitalPinToBitMask(dcPin); 39 | csPort = (PortReg *)portOutputRegister(digitalPinToPort(csPin)); 40 | csPinMask = digitalPinToBitMask(csPin); 41 | #endif 42 | 43 | SSD1306_DESELECT; 44 | 45 | // Set up SPI peripheral 46 | if(needsInit) 47 | SPI.begin(); 48 | 49 | // Reset SSD1306 if requested and reset pin specified in constructor 50 | if(rstPin >= 0) { 51 | pinMode( rstPin, OUTPUT); 52 | digitalWrite(rstPin, HIGH); 53 | delay(1); // VDD goes high at start, pause for 1 ms 54 | digitalWrite(rstPin, LOW); // Bring reset low 55 | delay(10); // Wait 10 ms 56 | digitalWrite(rstPin, HIGH); // Bring out of reset 57 | } 58 | } 59 | 60 | void SSD1306_SPI_Driver::startTransaction() 61 | { 62 | SSD1306_SELECT; 63 | 64 | #ifdef SPI_HAS_TRANSACTION 65 | spi->beginTransaction(spiSettings); 66 | #endif 67 | } 68 | 69 | void SSD1306_SPI_Driver::sendCommand(uint8_t cmd) 70 | { 71 | SSD1306_MODE_COMMAND; 72 | (void)spi->transfer(cmd); 73 | } 74 | 75 | void SSD1306_SPI_Driver::sendCommands(const uint8_t *cmds, size_t size) 76 | { 77 | SSD1306_MODE_COMMAND; 78 | while(size--) spi->transfer(pgm_read_byte(cmds++)); 79 | } 80 | 81 | void SSD1306_SPI_Driver::sendData(const uint8_t * data, size_t size) 82 | { 83 | SSD1306_MODE_DATA; 84 | while(size--) spi->transfer(*data++); 85 | } 86 | 87 | void SSD1306_SPI_Driver::endTransaction() 88 | { 89 | SSD1306_DESELECT; 90 | 91 | #ifdef SPI_HAS_TRANSACTION 92 | spi->endTransaction(); 93 | #endif 94 | } 95 | -------------------------------------------------------------------------------- /Libs/Adafruit_SSD1306/ssd1306_spi_driver.h: -------------------------------------------------------------------------------- 1 | #ifndef SSD1306_SPI_DRIVER_H 2 | #define SSD1306_SPI_DRIVER_H 3 | 4 | #include "Adafruit_SSD1306.h" 5 | 6 | #if defined(__AVR__) 7 | typedef volatile uint8_t PortReg; 8 | typedef uint8_t PortMask; 9 | #define HAVE_PORTREG 10 | #elif defined(__SAM3X8E__) 11 | typedef volatile RwReg PortReg; 12 | typedef uint32_t PortMask; 13 | #define HAVE_PORTREG 14 | #elif defined(__arm__) || defined(ARDUINO_FEATHER52) 15 | typedef volatile uint32_t PortReg; 16 | typedef uint32_t PortMask; 17 | #define HAVE_PORTREG 18 | #endif 19 | 20 | #if defined(ARDUINO_STM32_FEATHER) 21 | typedef class HardwareSPI SPIClass; 22 | #endif 23 | 24 | /*! 25 | @brief Hardware SPI driver for SSD1306 display 26 | 27 | This class implements communication over the SPI interface. The class encapsulate all the work 28 | related to hardware interfaces including initialization, configuration, and transferring the data 29 | */ 30 | class SSD1306_SPI_Driver : public ISSD1306Driver 31 | { 32 | // SPI connection use standard MOSI and SCLK pins plus Data/Command and Chip Select pins 33 | int8_t dcPin, csPin; 34 | 35 | #ifdef HAVE_PORTREG 36 | PortReg *dcPort, *csPort; 37 | PortMask dcPinMask, csPinMask; 38 | #endif 39 | 40 | // Driver may also reset the display if dedicated line is connected to rstPin 41 | int8_t rstPin; 42 | 43 | // The hardware interface to deal with 44 | SPIClass * spi; 45 | 46 | #if defined(SPI_HAS_TRANSACTION) 47 | SPISettings spiSettings; 48 | #endif 49 | 50 | // Do a spi->begin() during initialization 51 | bool needsInit; 52 | 53 | public: 54 | /*! 55 | @brief Constructor for SPI driver. 56 | @param dc_pin 57 | Data/command pin (using Arduino pin numbering), selects whether 58 | display is receiving commands (low) or data (high). 59 | @param cs_pin 60 | Chip-select pin (using Arduino pin numbering) for sharing the 61 | bus with other devices. Active low. 62 | @param rst_pin 63 | Reset pin if specified (using Arduino pin numbering), or -1 if not used 64 | (some displays might be wired to share the microcontroller's 65 | reset pin). If the pin is not -1, a hard reset will be performed before 66 | initializing the display. If using multiple SSD1306 displays on the same 67 | bus, and if they all share the same reset pin, you should only pass reset 68 | pin number on the first display being initialized, and -1 on all others 69 | Default if unspecified is -1. 70 | @param spi 71 | Pointer to an existing SPIClass instance - the actual hardware interface to 72 | communicate with. 73 | @param periphBegin 74 | Perform SPI peripheral initialization (in case if caller does not call 75 | spi->begin() elsewhere) 76 | @param bitrate 77 | SPI clock rate for transfers to this display. Default if 78 | unspecified is 8000000UL (8 MHz). 79 | @return SSD1306_SPI_Driver object. 80 | */ 81 | SSD1306_SPI_Driver(int8_t dc_pin, int8_t cs_pin, int8_t rst_pin = -1, SPIClass *spi = &SPI, bool periphBegin = true, uint32_t bitrate=8000000UL); 82 | 83 | virtual void begin(); 84 | virtual void startTransaction(); 85 | virtual void sendCommand(uint8_t cmd); 86 | virtual void sendCommands(const uint8_t *cmds, size_t size); 87 | virtual void sendData(const uint8_t * data, size_t size); 88 | virtual void endTransaction(); 89 | }; 90 | 91 | #endif // SSD1306_SPI_DRIVER_H 92 | -------------------------------------------------------------------------------- /Libs/Adafruit_SSD1306/ssd1306_sw_spi_driver.cpp: -------------------------------------------------------------------------------- 1 | #include "ssd1306_sw_spi_driver.h" 2 | 3 | #ifdef HAVE_PORTREG 4 | #define SSD1306_SELECT *csPort &= ~csPinMask; ///< Device select 5 | #define SSD1306_DESELECT *csPort |= csPinMask; ///< Device deselect 6 | #define SSD1306_MODE_COMMAND *dcPort &= ~dcPinMask; ///< Command mode 7 | #define SSD1306_MODE_DATA *dcPort |= dcPinMask; ///< Data mode 8 | #else 9 | #define SSD1306_SELECT digitalWrite(csPin, LOW); ///< Device select 10 | #define SSD1306_DESELECT digitalWrite(csPin, HIGH); ///< Device deselect 11 | #define SSD1306_MODE_COMMAND digitalWrite(dcPin, LOW); ///< Command mode 12 | #define SSD1306_MODE_DATA digitalWrite(dcPin, HIGH); ///< Data mode 13 | #endif 14 | 15 | 16 | SSD1306_SW_SPI_Driver::SSD1306_SW_SPI_Driver(int8_t mosi_pin, int8_t sclk_pin, int8_t dc_pin, int8_t cs_pin, int8_t rst_pin) 17 | : mosiPin(mosi_pin) 18 | , clkPin(sclk_pin) 19 | , dcPin(dc_pin) 20 | , csPin(cs_pin) 21 | , rstPin(rst_pin) 22 | { 23 | } 24 | 25 | void SSD1306_SW_SPI_Driver::begin() 26 | { 27 | // set pins modes 28 | pinMode(dcPin, OUTPUT); // Set data/command pin as output 29 | pinMode(csPin, OUTPUT); // Same for chip select 30 | 31 | #ifdef HAVE_PORTREG 32 | dcPort = (PortReg *)portOutputRegister(digitalPinToPort(dcPin)); 33 | dcPinMask = digitalPinToBitMask(dcPin); 34 | csPort = (PortReg *)portOutputRegister(digitalPinToPort(csPin)); 35 | csPinMask = digitalPinToBitMask(csPin); 36 | #endif 37 | 38 | SSD1306_DESELECT 39 | 40 | // MOSI and SCLK outputs 41 | pinMode(mosiPin, OUTPUT); 42 | pinMode(clkPin , OUTPUT); 43 | 44 | #ifdef HAVE_PORTREG 45 | mosiPort = (PortReg *)portOutputRegister(digitalPinToPort(mosiPin)); 46 | mosiPinMask = digitalPinToBitMask(mosiPin); 47 | clkPort = (PortReg *)portOutputRegister(digitalPinToPort(clkPin)); 48 | clkPinMask = digitalPinToBitMask(clkPin); 49 | *clkPort &= ~clkPinMask; // Clock low 50 | #else 51 | digitalWrite(clkPin, LOW); // Clock low 52 | #endif 53 | 54 | // Reset SSD1306 if requested and reset pin specified in constructor 55 | if(rstPin >= 0) { 56 | pinMode( rstPin, OUTPUT); 57 | digitalWrite(rstPin, HIGH); 58 | delay(1); // VDD goes high at start, pause for 1 ms 59 | digitalWrite(rstPin, LOW); // Bring reset low 60 | delay(10); // Wait 10 ms 61 | digitalWrite(rstPin, HIGH); // Bring out of reset 62 | } 63 | } 64 | 65 | inline void SSD1306_SW_SPI_Driver::fastSPIwrite(uint8_t d) 66 | { 67 | for(uint8_t bit = 0x80; bit; bit >>= 1) 68 | { 69 | #ifdef HAVE_PORTREG 70 | if(d & bit) *mosiPort |= mosiPinMask; 71 | else *mosiPort &= ~mosiPinMask; 72 | *clkPort |= clkPinMask; // Clock high 73 | *clkPort &= ~clkPinMask; // Clock low 74 | #else 75 | digitalWrite(mosiPin, d & bit); 76 | digitalWrite(clkPin , HIGH); 77 | digitalWrite(clkPin , LOW); 78 | #endif 79 | } 80 | } 81 | 82 | void SSD1306_SW_SPI_Driver::startTransaction() 83 | { 84 | SSD1306_SELECT; 85 | } 86 | 87 | void SSD1306_SW_SPI_Driver::sendCommand(uint8_t cmd) 88 | { 89 | SSD1306_MODE_COMMAND; 90 | fastSPIwrite(cmd); 91 | } 92 | 93 | void SSD1306_SW_SPI_Driver::sendCommands(const uint8_t *cmds, size_t size) 94 | { 95 | SSD1306_MODE_COMMAND; 96 | while(size--) fastSPIwrite(pgm_read_byte(cmds++)); 97 | } 98 | 99 | void SSD1306_SW_SPI_Driver::sendData(const uint8_t * data, size_t size) 100 | { 101 | SSD1306_MODE_DATA; 102 | while(size--) fastSPIwrite(*data++); 103 | } 104 | 105 | void SSD1306_SW_SPI_Driver::endTransaction() 106 | { 107 | SSD1306_DESELECT; 108 | } 109 | -------------------------------------------------------------------------------- /Libs/Adafruit_SSD1306/ssd1306_sw_spi_driver.h: -------------------------------------------------------------------------------- 1 | #ifndef SSD1306_SW_SPI_DRIVER_H 2 | #define SSD1306_SW_SPI_DRIVER_H 3 | 4 | #include "Adafruit_SSD1306.h" 5 | 6 | #if defined(__AVR__) 7 | typedef volatile uint8_t PortReg; 8 | typedef uint8_t PortMask; 9 | #define HAVE_PORTREG 10 | #elif defined(__SAM3X8E__) 11 | typedef volatile RwReg PortReg; 12 | typedef uint32_t PortMask; 13 | #define HAVE_PORTREG 14 | #elif defined(__arm__) || defined(ARDUINO_FEATHER52) 15 | typedef volatile uint32_t PortReg; 16 | typedef uint32_t PortMask; 17 | #define HAVE_PORTREG 18 | #endif 19 | 20 | /*! 21 | @brief Software SPI driver for SSD1306 display 22 | 23 | This class implements communication over software implementation of SPI interface. The class 24 | encapsulate all the work related to hardware interfaces including initialization used pins, 25 | and transferring the data 26 | */ 27 | class SSD1306_SW_SPI_Driver : public ISSD1306Driver 28 | { 29 | // SPI connection use standard MOSI and SCLK pins plus Data/Command and Chip Select pins 30 | int8_t mosiPin, clkPin, dcPin, csPin; 31 | #ifdef HAVE_PORTREG 32 | PortReg *mosiPort , *clkPort , *dcPort , *csPort; 33 | PortMask mosiPinMask, clkPinMask, dcPinMask, csPinMask; 34 | #endif 35 | 36 | // Driver may also reset the display if dedicated line is connected to rstPin 37 | int8_t rstPin; 38 | 39 | void fastSPIwrite(uint8_t c); 40 | 41 | public: 42 | /*! 43 | @brief Constructor for software SPI driver. 44 | @param mosi_pin 45 | MOSI (master out, slave in) pin (using Arduino pin numbering). 46 | This transfers serial data from microcontroller to display. 47 | @param sclk_pin 48 | SCLK (serial clock) pin (using Arduino pin numbering). 49 | This clocks each bit from MOSI. 50 | @param dc_pin 51 | Data/command pin (using Arduino pin numbering), selects whether 52 | display is receiving commands (low) or data (high). 53 | @param cs_pin 54 | Chip-select pin (using Arduino pin numbering) for sharing the 55 | bus with other devices. Active low. 56 | @param rst_pin 57 | Reset pin if specified (using Arduino pin numbering), or -1 if not used 58 | (some displays might be wired to share the microcontroller's 59 | reset pin). If the pin is not -1, a hard reset will be performed before 60 | initializing the display. If using multiple SSD1306 displays on the same 61 | bus, and if they all share the same reset pin, you should only pass reset 62 | pin number on the first display being initialized, and -1 on all others 63 | Default if unspecified is -1. 64 | @return SSD1306_SW_SPI_Driver object. 65 | */ 66 | SSD1306_SW_SPI_Driver(int8_t mosi_pin, int8_t sclk_pin, int8_t dc_pin, int8_t cs_pin, int8_t rst_pin = -1); 67 | 68 | virtual void begin(); 69 | virtual void startTransaction(); 70 | virtual void sendCommand(uint8_t cmd); 71 | virtual void sendCommands(const uint8_t *cmds, size_t size); 72 | virtual void sendData(const uint8_t * data, size_t size); 73 | virtual void endTransaction(); 74 | }; 75 | 76 | #endif // SSD1306_SPI_DRIVER_H 77 | -------------------------------------------------------------------------------- /Libs/FreeRTOS/Arduino_FreeRTOS.c: -------------------------------------------------------------------------------- 1 | #include "Arduino_FreeRTOS.h" 2 | 3 | void vApplicationIdleHook() { 4 | 5 | } 6 | 7 | void vApplicationStackOverflowHook( TaskHandle_t pxTask, char *pcTaskName ) 8 | { 9 | ( void ) pcTaskName; 10 | ( void ) pxTask; 11 | 12 | /* Run time stack overflow checking is performed if 13 | configCHECK_FOR_STACK_OVERFLOW is defined to 1 or 2. This hook 14 | function is called if a stack overflow is detected. */ 15 | //taskDISABLE_INTERRUPTS(); 16 | for( ;; ); 17 | } 18 | 19 | void vApplicationMallocFailedHook( void ) 20 | { 21 | /* vApplicationMallocFailedHook() will only be called if 22 | configUSE_MALLOC_FAILED_HOOK is set to 1 in FreeRTOSConfig.h. It is a hook 23 | function that will get called if a call to pvPortMalloc() fails.*/ 24 | //taskDISABLE_INTERRUPTS(); 25 | for( ;; ); 26 | } 27 | -------------------------------------------------------------------------------- /Libs/FreeRTOS/Arduino_FreeRTOS.h: -------------------------------------------------------------------------------- 1 | #ifndef ARDUINO_FREERTOS 2 | #define ARDUINO_FREERTOS 3 | 4 | #ifdef __cplusplus 5 | extern "C"{ 6 | #endif 7 | 8 | #include "FreeRTOS.h" 9 | #include "task.h" 10 | #include "queue.h" 11 | #include "semphr.h" 12 | 13 | #ifdef __cplusplus 14 | } 15 | #endif 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /Libs/FreeRTOS/readme.txt: -------------------------------------------------------------------------------- 1 | Each real time kernel port consists of three files that contain the core kernel 2 | components and are common to every port, and one or more files that are 3 | specific to a particular microcontroller and or compiler. 4 | 5 | + The FreeRTOS/Source directory contains the three files that are common to 6 | every port - list.c, queue.c and tasks.c. The kernel is contained within these 7 | three files. croutine.c implements the optional co-routine functionality - which 8 | is normally only used on very memory limited systems. 9 | 10 | + The FreeRTOS/Source/Portable directory contains the files that are specific to 11 | a particular microcontroller and or compiler. 12 | 13 | + The FreeRTOS/Source/include directory contains the real time kernel header 14 | files. 15 | 16 | See the readme file in the FreeRTOS/Source/Portable directory for more 17 | information. -------------------------------------------------------------------------------- /Libs/FreeRTOS/stdint.readme: -------------------------------------------------------------------------------- 1 | 2 | #ifndef FREERTOS_STDINT 3 | #define FREERTOS_STDINT 4 | 5 | /******************************************************************************* 6 | * THIS IS NOT A FULL stdint.h IMPLEMENTATION - It only contains the definitions 7 | * necessary to build the FreeRTOS code. It is provided to allow FreeRTOS to be 8 | * built using compilers that do not provide their own stdint.h definition. 9 | * 10 | * To use this file: 11 | * 12 | * 1) Copy this file into the directory that contains your FreeRTOSConfig.h 13 | * header file, as that directory will already be in the compilers include 14 | * path. 15 | * 16 | * 2) Rename the copied file stdint.h. 17 | * 18 | */ 19 | 20 | typedef signed char int8_t; 21 | typedef unsigned char uint8_t; 22 | typedef short int16_t; 23 | typedef unsigned short uint16_t; 24 | typedef long int32_t; 25 | typedef unsigned long uint32_t; 26 | 27 | #endif /* FREERTOS_STDINT */ 28 | -------------------------------------------------------------------------------- /Libs/HAL/STM32F1/CMSIS_Inc/stm32f103xe.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/grafalex82/GPSLogger/4c53cab01d60977f78a8cb53cc879c3dcd655230/Libs/HAL/STM32F1/CMSIS_Inc/stm32f103xe.h -------------------------------------------------------------------------------- /Libs/HAL/STM32F1/CMSIS_Inc/stm32f1xx.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/grafalex82/GPSLogger/4c53cab01d60977f78a8cb53cc879c3dcd655230/Libs/HAL/STM32F1/CMSIS_Inc/stm32f1xx.h -------------------------------------------------------------------------------- /Libs/HAL/STM32F1/HAL_Inc/stm32_assert_template.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32_assert.h 4 | * @author MCD Application Team 5 | * @brief STM32 assert template file. 6 | * This file should be copied to the application folder and renamed 7 | * to stm32_assert.h. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT(c) 2016 STMicroelectronics

12 | * 13 | * Redistribution and use in source and binary forms, with or without modification, 14 | * are permitted provided that the following conditions are met: 15 | * 1. Redistributions of source code must retain the above copyright notice, 16 | * this list of conditions and the following disclaimer. 17 | * 2. Redistributions in binary form must reproduce the above copyright notice, 18 | * this list of conditions and the following disclaimer in the documentation 19 | * and/or other materials provided with the distribution. 20 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 21 | * may be used to endorse or promote products derived from this software 22 | * without specific prior written permission. 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 ARE 27 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 32 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 33 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 | * 35 | ****************************************************************************** 36 | */ 37 | 38 | /* Define to prevent recursive inclusion -------------------------------------*/ 39 | #ifndef __STM32_ASSERT_H 40 | #define __STM32_ASSERT_H 41 | 42 | #ifdef __cplusplus 43 | extern "C" { 44 | #endif 45 | 46 | /* Exported types ------------------------------------------------------------*/ 47 | /* Exported constants --------------------------------------------------------*/ 48 | /* Includes ------------------------------------------------------------------*/ 49 | /* Exported macro ------------------------------------------------------------*/ 50 | #ifdef USE_FULL_ASSERT 51 | /** 52 | * @brief The assert_param macro is used for function's parameters check. 53 | * @param expr: If expr is false, it calls assert_failed function 54 | * which reports the name of the source file and the source 55 | * line number of the call that failed. 56 | * If expr is true, it returns no value. 57 | * @retval None 58 | */ 59 | #define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__)) 60 | /* Exported functions ------------------------------------------------------- */ 61 | void assert_failed(uint8_t *file, uint32_t line); 62 | #else 63 | #define assert_param(expr) ((void)0U) 64 | #endif /* USE_FULL_ASSERT */ 65 | 66 | #ifdef __cplusplus 67 | } 68 | #endif 69 | 70 | #endif /* __STM32_ASSERT_H */ 71 | 72 | 73 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 74 | -------------------------------------------------------------------------------- /Libs/HAL/STM32F1/HAL_Src/stm32f1xx_hal_timebase_rtc_alarm_template.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/grafalex82/GPSLogger/4c53cab01d60977f78a8cb53cc879c3dcd655230/Libs/HAL/STM32F1/HAL_Src/stm32f1xx_hal_timebase_rtc_alarm_template.c -------------------------------------------------------------------------------- /Libs/MiniArduino/Print.h: -------------------------------------------------------------------------------- 1 | /* 2 | Print.h - Base class that provides print() and println() 3 | Copyright (c) 2008 David A. Mellis. All right reserved. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef Print_h 21 | #define Print_h 22 | 23 | #include 24 | #include // for size_t 25 | 26 | #include "WString.h" 27 | #include "Printable.h" 28 | 29 | #define DEC 10 30 | #define HEX 16 31 | #define OCT 8 32 | #ifdef BIN // Prevent warnings if BIN is previously defined in "iotnx4.h" or similar 33 | #undef BIN 34 | #endif 35 | #define BIN 2 36 | 37 | typedef unsigned long long uint64_t; 38 | typedef long long int64_t; 39 | 40 | class Print 41 | { 42 | private: 43 | int write_error; 44 | size_t printNumber(unsigned long long, uint8_t); 45 | size_t printFloat(double, uint8_t); 46 | protected: 47 | void setWriteError(int err = 1) { write_error = err; } 48 | public: 49 | Print() : write_error(0) {} 50 | 51 | int getWriteError() { return write_error; } 52 | void clearWriteError() { setWriteError(0); } 53 | 54 | virtual size_t write(uint8_t) = 0; 55 | size_t write(const char *str) { 56 | if (str == NULL) return 0; 57 | return write((const uint8_t *)str, strlen(str)); 58 | } 59 | virtual size_t write(const uint8_t *buffer, size_t size); 60 | size_t write(const char *buffer, size_t size) { 61 | return write((const uint8_t *)buffer, size); 62 | } 63 | 64 | size_t print(const __FlashStringHelper *); 65 | size_t print(const String &); 66 | size_t print(const char[]); 67 | size_t print(char); 68 | size_t print(unsigned char, int = DEC); 69 | size_t print(int, int = DEC); 70 | size_t print(unsigned int, int = DEC); 71 | size_t print(long, int = DEC); 72 | size_t print(unsigned long, int = DEC); 73 | size_t print(long long, int = DEC); 74 | size_t print(unsigned long long, int = DEC); 75 | size_t print(double, int = 2); 76 | size_t print(const Printable&); 77 | 78 | size_t println(const __FlashStringHelper *); 79 | size_t println(const String &s); 80 | size_t println(const char[]); 81 | size_t println(char); 82 | size_t println(unsigned char, int = DEC); 83 | size_t println(int, int = DEC); 84 | size_t println(unsigned int, int = DEC); 85 | size_t println(long, int = DEC); 86 | size_t println(unsigned long, int = DEC); 87 | size_t println(long long, int = DEC); 88 | size_t println(unsigned long long, int = DEC); 89 | size_t println(double, int = 2); 90 | size_t println(const Printable&); 91 | size_t println(void); 92 | }; 93 | 94 | #endif 95 | -------------------------------------------------------------------------------- /Libs/MiniArduino/Printable.h: -------------------------------------------------------------------------------- 1 | /* 2 | Printable.h - Interface class that allows printing of complex types 3 | Copyright (c) 2011 Adrian McEwen. All right reserved. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef Printable_h 21 | #define Printable_h 22 | 23 | #include 24 | 25 | class Print; 26 | 27 | /** The Printable class provides a way for new classes to allow themselves to be printed. 28 | By deriving from Printable and implementing the printTo method, it will then be possible 29 | for users to print out instances of this class by passing them into the usual 30 | Print::print and Print::println methods. 31 | */ 32 | 33 | class Printable 34 | { 35 | public: 36 | virtual size_t printTo(Print& p) const = 0; 37 | }; 38 | 39 | #endif 40 | 41 | -------------------------------------------------------------------------------- /Libs/MiniArduino/abi.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014 Arduino. All right reserved. 3 | 4 | This library is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | This library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | See the GNU Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with this library; if not, write to the Free Software 16 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 17 | */ 18 | 19 | #include 20 | 21 | extern "C" void __cxa_pure_virtual(void) __attribute__ ((__noreturn__)); 22 | extern "C" void __cxa_deleted_virtual(void) __attribute__ ((__noreturn__)); 23 | 24 | void __cxa_pure_virtual(void) { 25 | // We might want to write some diagnostics to uart in this case 26 | //std::terminate(); 27 | while (1) 28 | ; 29 | } 30 | 31 | void __cxa_deleted_virtual(void) { 32 | // We might want to write some diagnostics to uart in this case 33 | //std::terminate(); 34 | while (1) 35 | ; 36 | } 37 | 38 | -------------------------------------------------------------------------------- /Libs/MiniArduino/avr/pgmspace.h: -------------------------------------------------------------------------------- 1 | #ifndef __PGMSPACE_H_ 2 | #define __PGMSPACE_H_ 1 3 | 4 | #include 5 | 6 | #define PROGMEM 7 | #define PGM_P const char * 8 | #define PSTR(str) (str) 9 | 10 | #define _SFR_BYTE(n) (n) 11 | 12 | typedef void prog_void; 13 | typedef char prog_char; 14 | typedef unsigned char prog_uchar; 15 | typedef int8_t prog_int8_t; 16 | typedef uint8_t prog_uint8_t; 17 | typedef int16_t prog_int16_t; 18 | typedef uint16_t prog_uint16_t; 19 | typedef int32_t prog_int32_t; 20 | typedef uint32_t prog_uint32_t; 21 | 22 | #define memcpy_P(dest, src, num) memcpy((dest), (src), (num)) 23 | #define strcpy_P(dest, src) strcpy((dest), (src)) 24 | #define strcat_P(dest, src) strcat((dest), (src)) 25 | #define strcmp_P(a, b) strcmp((a), (b)) 26 | #define strstr_P(a, b) strstr((a), (b)) 27 | #define strlen_P(a) strlen((a)) 28 | #define sprintf_P(s, f, ...) sprintf((s), (f), __VA_ARGS__) 29 | 30 | #define pgm_read_byte(addr) (*(const unsigned char *)(addr)) 31 | #define pgm_read_word(addr) (*(const unsigned short *)(addr)) 32 | #define pgm_read_dword(addr) (*(const unsigned long *)(addr)) 33 | #define pgm_read_float(addr) (*(const float *)(addr)) 34 | 35 | #define pgm_read_byte_near(addr) pgm_read_byte(addr) 36 | #define pgm_read_word_near(addr) pgm_read_word(addr) 37 | #define pgm_read_dword_near(addr) pgm_read_dword(addr) 38 | #define pgm_read_float_near(addr) pgm_read_float(addr) 39 | #define pgm_read_byte_far(addr) pgm_read_byte(addr) 40 | #define pgm_read_word_far(addr) pgm_read_word(addr) 41 | #define pgm_read_dword_far(addr) pgm_read_dword(addr) 42 | #define pgm_read_float_far(addr) pgm_read_float(addr) 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /Libs/MiniArduino/stm32/stm32_clock.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2017 Daniel Fekete 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy 5 | of this software and associated documentation files (the "Software"), to deal 6 | in the Software without restriction, including without limitation the rights 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the Software is 9 | furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in all 12 | copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | SOFTWARE. 21 | */ 22 | 23 | /** 24 | * Implementation of Arduino methods: 25 | * millis() https://www.arduino.cc/en/Reference/Millis 26 | * micros() https://www.arduino.cc/en/Reference/Micros 27 | * delay() https://www.arduino.cc/en/Reference/Delay 28 | * TODO delayMicroseconds() https://www.arduino.cc/en/Reference/DelayMicroseconds 29 | */ 30 | #ifndef STM32_CLOCK_H 31 | #define STM32_CLOCK_H 32 | 33 | #ifdef __cplusplus 34 | extern "C"{ 35 | #endif 36 | 37 | extern void yield(); 38 | 39 | inline void delay(unsigned long millis) { 40 | uint32_t tickstart = 0; 41 | tickstart = HAL_GetTick(); 42 | while((HAL_GetTick() - tickstart) < millis) { 43 | yield(); 44 | } 45 | } 46 | 47 | inline uint32_t millis() { 48 | return HAL_GetTick(); 49 | } 50 | 51 | inline uint32_t micros() { 52 | // by Pito 4/2017 53 | uint32_t m = HAL_GetTick(); 54 | uint32_t u = SysTick->LOAD - SysTick->VAL; 55 | uint32_t m1 = HAL_GetTick(); 56 | uint32_t u1 = SysTick->LOAD - SysTick->VAL; 57 | 58 | if (m1 > m) { 59 | return ( m1 * 1000 + (u1 * 1000) / SysTick->LOAD); 60 | } else { 61 | return ( m * 1000 + (u * 1000) / SysTick->LOAD); 62 | } 63 | } 64 | 65 | inline void delayMicroseconds(uint32_t microseconds){ 66 | uint32_t start = micros(); 67 | 68 | while(start + microseconds > micros()) { 69 | yield(); 70 | } 71 | } 72 | 73 | #ifdef __cplusplus 74 | } 75 | #endif 76 | 77 | #endif 78 | -------------------------------------------------------------------------------- /Libs/MiniArduino/stm32/stm32_def.h: -------------------------------------------------------------------------------- 1 | #ifndef STM32_DEF_H 2 | #define STM32_DEF_H 3 | 4 | //#include "stm32_build_defines.h" 5 | 6 | #ifdef STM32F0 7 | #include "stm32f0xx.h" 8 | #include "stm32f0xx_hal.h" 9 | #elif defined(STM32F1) 10 | #include "stm32f1xx.h" 11 | #include "stm32f1xx_hal.h" 12 | #elif defined(STM32F2) 13 | #include "stm32f2xx.h" 14 | #include "stm32f2xx_hal.h" 15 | #elif defined(STM32F3) 16 | #include "stm32f3xx.h" 17 | #include "stm32f3xx_hal.h" 18 | #elif defined(STM32F4) 19 | #include "stm32f4xx.h" 20 | #include "stm32f4xx_hal.h" 21 | #elif defined(STM32F7) 22 | #include "stm32f7xx.h" 23 | #include "stm32f7xx_hal.h" 24 | #elif defined(STM32L0) 25 | #include "stm32l0xx.h" 26 | #include "stm32l0xx_hal.h" 27 | #elif defined(STM32L1) 28 | #include "stm32l1xx.h" 29 | #include "stm32l1xx_hal.h" 30 | #elif defined(STM32L4) 31 | #include "stm32l4xx.h" 32 | #include "stm32l4xx_hal.h" 33 | #else 34 | #error "STM32XX is not defined in boards.txt" 35 | #endif 36 | 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /Libs/NeoGPS/CosaCompat.h: -------------------------------------------------------------------------------- 1 | #ifndef COSACOMPAT_H 2 | #define COSACOMPAT_H 3 | 4 | #ifdef __AVR__ 5 | 6 | #include 7 | 8 | #else 9 | 10 | #define PGM_P const char * 11 | 12 | #endif 13 | 14 | typedef PGM_P str_P; 15 | #define __PROGMEM PROGMEM 16 | 17 | #endif -------------------------------------------------------------------------------- /Libs/NeoGPS/DMS.h: -------------------------------------------------------------------------------- 1 | #ifndef DMS_H 2 | #define DMS_H 3 | 4 | //------------------------------------------------------ 5 | // @file DMS.h 6 | // @version 1.0 7 | // 8 | // @section License 9 | // Copyright (C) 2016, SlashDevin 10 | // 11 | // This library is free software; you can redistribute it and/or 12 | // modify it under the terms of the GNU Lesser General Public 13 | // License as published by the Free Software Foundation; either 14 | // version 2.1 of the License, or (at your option) any later version. 15 | // 16 | // This library is distributed in the hope that it will be useful, 17 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 | // Lesser General Public License for more details. 20 | // 21 | 22 | #include "NeoGPS_cfg.h" 23 | #include 24 | class Print; 25 | 26 | enum Hemisphere_t { NORTH_H = 0, SOUTH_H = 1, EAST_H = 0, WEST_H = 1 }; 27 | 28 | class DMS_t 29 | { 30 | public: 31 | uint8_t degrees; 32 | uint8_t minutes ;//NEOGPS_BF(6); 33 | Hemisphere_t hemisphere ;//NEOGPS_BF(2); compiler bug! 34 | uint8_t seconds_whole NEOGPS_BF(6); 35 | uint16_t seconds_frac NEOGPS_BF(10); // 1000ths 36 | 37 | void init() { degrees = minutes = seconds_whole = seconds_frac = 0; 38 | hemisphere = NORTH_H; } 39 | 40 | float secondsF() const { return seconds_whole + 0.001 * seconds_frac; }; 41 | char NS () const { return (hemisphere == SOUTH_H) ? 'S' : 'N'; }; 42 | char EW () const { return (hemisphere == WEST_H) ? 'W' : 'E'; }; 43 | 44 | //............................................................................. 45 | // A utility function to convert from integer 'lat' or 'lon', scaled by 10^7 46 | 47 | void From( int32_t deg_1E7 ); 48 | 49 | // Print DMS as the funky NMEA DDDMM.mmmm format 50 | void printDDDMMmmmm( Print & outs ) const; 51 | 52 | } NEOGPS_PACKED; 53 | 54 | extern Print & operator << ( Print & outs, const DMS_t & ); 55 | 56 | #endif -------------------------------------------------------------------------------- /Libs/NeoGPS/GPSTime.cpp: -------------------------------------------------------------------------------- 1 | #include "GPSTime.h" 2 | 3 | uint8_t GPSTime::leap_seconds = 0; 4 | NeoGPS::clock_t GPSTime::s_start_of_week = 0; 5 | -------------------------------------------------------------------------------- /Libs/NeoGPS/GPSTime.h: -------------------------------------------------------------------------------- 1 | #ifndef GPSTIME_H 2 | #define GPSTIME_H 3 | 4 | #include "NeoTime.h" 5 | 6 | class GPSTime 7 | { 8 | GPSTime(); 9 | 10 | static NeoGPS::clock_t s_start_of_week; 11 | 12 | public: 13 | 14 | /** 15 | * GPS time is offset from UTC by a number of leap seconds. To convert a GPS 16 | * time to UTC time, the current number of leap seconds must be known. 17 | * See http://en.wikipedia.org/wiki/Global_Positioning_System#Leap_seconds 18 | */ 19 | static uint8_t leap_seconds; 20 | 21 | /** 22 | * Some receivers report time WRT start of the current week, defined as 23 | * Sunday 00:00:00. To save fairly expensive date/time calculations, 24 | * the UTC start of week is cached 25 | */ 26 | static void start_of_week( NeoGPS::time_t & now ) 27 | { 28 | now.set_day(); 29 | s_start_of_week = 30 | (NeoGPS::clock_t) now - 31 | (NeoGPS::clock_t) ((((now.day-1 ) * 24L + 32 | now.hours ) * 60L + 33 | now.minutes) * 60L + 34 | now.seconds); 35 | } 36 | 37 | static NeoGPS::clock_t start_of_week() 38 | { 39 | return s_start_of_week; 40 | } 41 | 42 | /* 43 | * Convert a GPS time-of-week to UTC. 44 | * Requires /leap_seconds/ and /start_of_week/. 45 | */ 46 | static NeoGPS::clock_t TOW_to_UTC( uint32_t time_of_week ) 47 | { return (NeoGPS::clock_t) 48 | (start_of_week() + time_of_week - leap_seconds); } 49 | 50 | /** 51 | * Set /fix/ timestamp from a GPS time-of-week in milliseconds. 52 | * Requires /leap_seconds/ and /start_of_week/. 53 | **/ 54 | static bool from_TOWms 55 | ( uint32_t time_of_week_ms, NeoGPS::time_t &dt, uint16_t &ms ) 56 | { 57 | //trace << PSTR("from_TOWms(") << time_of_week_ms << PSTR("), sow = ") << start_of_week() << PSTR(", leap = ") << leap_seconds << endl; 58 | bool ok = (start_of_week() != 0) && (leap_seconds != 0); 59 | if (ok) { 60 | NeoGPS::clock_t tow_s = time_of_week_ms/1000UL; 61 | dt = TOW_to_UTC( tow_s ); 62 | ms = (uint16_t)(time_of_week_ms - tow_s*1000UL); 63 | } 64 | return ok; 65 | } 66 | }; 67 | 68 | #endif -------------------------------------------------------------------------------- /Libs/NeoGPS/GPSfix_cfg.h: -------------------------------------------------------------------------------- 1 | #ifndef GPS_FIX_CFG 2 | #define GPS_FIX_CFG 3 | 4 | /** 5 | * Enable/disable the storage for the members of a fix. 6 | * 7 | * Disabling a member prevents it from being parsed from a received message. 8 | * The disabled member cannot be accessed or stored, and its validity flag 9 | * would not be available. It will not be declared, and code that uses that 10 | * member will not compile. 11 | * 12 | * DATE and TIME are somewhat coupled in that they share a single `time_t`, 13 | * but they have separate validity flags. 14 | * 15 | * See also note regarding the DOP members, below. 16 | * 17 | */ 18 | 19 | #define GPS_FIX_DATE 20 | #define GPS_FIX_TIME 21 | #define GPS_FIX_LOCATION 22 | #define GPS_FIX_LOCATION_DMS 23 | #define GPS_FIX_ALTITUDE 24 | #define GPS_FIX_SPEED 25 | #define GPS_FIX_HEADING 26 | #define GPS_FIX_SATELLITES 27 | #define GPS_FIX_HDOP 28 | #define GPS_FIX_VDOP 29 | #define GPS_FIX_PDOP 30 | //#define GPS_FIX_LAT_ERR 31 | //#define GPS_FIX_LON_ERR 32 | //#define GPS_FIX_ALT_ERR 33 | #define GPS_FIX_GEOID_HEIGHT 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /Libs/NeoGPS/GPSport.h: -------------------------------------------------------------------------------- 1 | #ifndef GPSport_h 2 | #define GPSport_h 3 | 4 | //----------------------------------------------------------- 5 | // Pick the serial port to which the GPS device is connected. 6 | // 7 | // This file tries to guess which port a beginner should use. 8 | // If you already know which port and which library you want 9 | // to use for that port, DON'T INCLUDE THIS FILE. 10 | // Just declare it yourself, and remove this include from your INO! 11 | // 12 | // If you include , , 13 | // , *OR* before 14 | // this file, one of those ports will be used for 15 | // the GPS. 16 | // 17 | // It also defines USING_GPS_PORT, which can be used for printing 18 | // the selected device: 19 | // 20 | // Serial.println( "Looking for GPS device on " USING_GPS_PORT ); 21 | 22 | #if defined( SoftwareSerial_h ) 23 | #define SS_TYPE SoftwareSerial 24 | 25 | #elif defined( NeoSWSerial_h ) 26 | #define SS_TYPE NeoSWSerial 27 | 28 | #elif defined( AltSoftSerial_h ) 29 | AltSoftSerial gps_port; 30 | #define USING_GPS_PORT "AltSoftSerial" 31 | 32 | #elif defined( NeoICSerial_h ) 33 | NeoICSerial gps_port; 34 | #define USING_GPS_PORT "NeoICSerial" 35 | 36 | #elif defined( NeoHWSerial_h ) 37 | NeoHWSerial & gps_port = NeoSerial1; 38 | #define USING_GPS_PORT "NeoSerial1" 39 | 40 | #elif defined( UBRR1H ) | defined( ID_USART0 ) 41 | HardwareSerial & gps_port = Serial1; 42 | #define USING_GPS_PORT "Serial1" 43 | 44 | #else 45 | #error Unable to choose serial port for GPS device. \ 46 | You must include a serial header before "#include GPSport.h" in the INO! \ 47 | NeoSWSerial, NeoICSerial, NeoHWSerial, AltSoftSerial and SoftwareSerial are supported. 48 | #endif 49 | 50 | #ifdef SS_TYPE 51 | 52 | //--------------------------------------------------------------- 53 | // The current Board (an Uno?) does not have an extra serial port. 54 | // Use a software serial library to listen to the GPS device. 55 | // You should expect to get some RX errors, which may 56 | // prevent getting fix data every second. YMMV. 57 | 58 | // Arduino RX pin number that is connected to the GPS TX pin 59 | #ifndef RX_PIN 60 | #define RX_PIN 4 61 | #endif 62 | 63 | // Arduino TX pin number that is connected to the GPS RX pin 64 | #ifndef TX_PIN 65 | #define TX_PIN 3 66 | #endif 67 | 68 | SS_TYPE gps_port( RX_PIN, TX_PIN ); 69 | 70 | // A little preprocessor magic to get a nice string 71 | #define xstr(x) str(x) 72 | #define str(x) #x 73 | #define USING_GPS_PORT \ 74 | xstr(SS_TYPE) "( RX pin " xstr(RX_PIN) \ 75 | ", TX pin " xstr(TX_PIN) " )" 76 | 77 | #if defined(UBRR1H) 78 | // If you *really* want to do this, or you just happened 79 | // to include SoftwareSerial.h for something else, you're 80 | // better off *not* including this file. Just declare 81 | // your own gps_port in your INO file. 82 | 83 | #error You should be using Serial1 for the GPS device. \ 84 | Software serial libraries are very inefficient and unreliable when \ 85 | used for GPS communications! 86 | #endif 87 | 88 | #endif 89 | 90 | #endif -------------------------------------------------------------------------------- /Libs/NeoGPS/NeoGPS_cfg.h: -------------------------------------------------------------------------------- 1 | #ifndef NEOGPS_CFG 2 | #define NEOGPS_CFG 3 | 4 | /** 5 | * Enable/disable packed data structures. 6 | * 7 | * Enabling packed data structures will use two less-portable language 8 | * features of GCC to reduce RAM requirements. Although it was expected to slightly increase execution time and code size, the reverse is true on 8-bit AVRs: the code is smaller and faster with packing enabled. 9 | * 10 | * Disabling packed data structures will be very portable to other 11 | * platforms. NeoGPS configurations will use slightly more RAM, and on 12 | * 8-bit AVRs, the speed is slightly slower, and the code is slightly 13 | * larger. There may be no choice but to disable packing on processors 14 | * that do not support packed structures. 15 | * 16 | * There may also be compiler-specific switches that affect packing and the 17 | * code which accesses packed members. YMMV. 18 | **/ 19 | 20 | #ifdef __AVR__ 21 | #define NEOGPS_PACKED_DATA 22 | #endif 23 | 24 | //------------------------------------------------------------------------ 25 | // Based on the above define, choose which set of packing macros should 26 | // be used in the rest of the NeoGPS package. Do not change these defines. 27 | 28 | #ifdef NEOGPS_PACKED_DATA 29 | 30 | // This is for specifying the number of bits to be used for a 31 | // member of a struct. Booleans are typically one bit. 32 | #define NEOGPS_BF(b) :b 33 | 34 | // This is for requesting the compiler to pack the struct or class members 35 | // "as closely as possible". This is a compiler-dependent interpretation. 36 | #define NEOGPS_PACKED __attribute__((packed)) 37 | 38 | #else 39 | 40 | // Let the compiler do whatever it wants. 41 | 42 | #define NEOGPS_PACKED 43 | #define NEOGPS_BF(b) 44 | 45 | #endif 46 | 47 | /* 48 | * Accommodate C++ compiler and IDE changes. 49 | * 50 | * Declaring constants as class data instead of instance data helps avoid 51 | * collisions with #define names, and allows the compiler to perform more 52 | * checks on their usage. 53 | * 54 | * Until C++ 10 and IDE 1.6.8, initialized class data constants 55 | * were declared like this: 56 | * 57 | * static const = ; 58 | * 59 | * Now, non-simple types (e.g., float) must be declared as 60 | * 61 | * static constexpr = ; 62 | * 63 | * The good news is that this allows the compiler to optimize out an 64 | * expression that is "promised" to be "evaluatable" as a constant. 65 | * The bad news is that it introduces a new language keyword, and the old 66 | * code raises an error. 67 | * 68 | * TODO: Evaluate the requirement for the "static" keyword. 69 | * TODO: Evaluate using a C++ version preprocessor symbol for the #if. 70 | * 71 | * The CONST_CLASS_DATA define will expand to the appropriate keywords. 72 | * 73 | */ 74 | 75 | #if (ARDUINO < 10606) | ((10700 <= ARDUINO) & (ARDUINO <= 10799)) | ((107000 <= ARDUINO) & (ARDUINO <= 107999)) | (__cpp_constexpr < 200704) 76 | 77 | #define CONST_CLASS_DATA static const 78 | 79 | #else 80 | 81 | #define CONST_CLASS_DATA static constexpr 82 | 83 | #endif 84 | 85 | #endif 86 | -------------------------------------------------------------------------------- /Libs/NeoGPS/Streamers.h: -------------------------------------------------------------------------------- 1 | #ifndef STREAMERS_H 2 | #define STREAMERS_H 3 | 4 | #include 5 | 6 | extern Print & operator <<( Print & outs, const bool b ); 7 | extern Print & operator <<( Print & outs, const char c ); 8 | extern Print & operator <<( Print & outs, const uint16_t v ); 9 | extern Print & operator <<( Print & outs, const uint32_t v ); 10 | extern Print & operator <<( Print & outs, const int32_t v ); 11 | extern Print & operator <<( Print & outs, const uint8_t v ); 12 | extern Print & operator <<( Print & outs, const __FlashStringHelper *s ); 13 | 14 | class gps_fix; 15 | 16 | /** 17 | * Print valid fix data to the given stream with the format 18 | * "status,dateTime,lat,lon,heading,speed,altitude,satellites, 19 | * hdop,vdop,pdop,lat_err,lon_err,alt_err" 20 | * The "header" above contains the actual compile-time configuration. 21 | * A comma-separated field will be empty if the data is NOT valid. 22 | * @param[in] outs output stream. 23 | * @param[in] fix gps_fix instance. 24 | * @return iostream. 25 | */ 26 | extern Print & operator <<( Print &outs, const gps_fix &fix ); 27 | 28 | class NMEAGPS; 29 | 30 | extern void trace_header( Print & outs ); 31 | extern void trace_all( Print & outs, const NMEAGPS &gps, const gps_fix &fix ); 32 | 33 | #endif -------------------------------------------------------------------------------- /Libs/NeoGPS/ublox/ubx_cfg.h: -------------------------------------------------------------------------------- 1 | #ifndef UBX_CFG_H 2 | #define UBX_CFG_H 3 | 4 | //-------------------------------------------------------------------- 5 | // Enable/disable the parsing of specific UBX messages. 6 | // 7 | // Configuring out a message prevents its fields from being parsed. 8 | // However, the message type will still be recognized by /decode/ and 9 | // stored in member /rx_msg/. No valid flags would be available. 10 | 11 | #define UBLOX_PARSE_STATUS 12 | #define UBLOX_PARSE_TIMEGPS 13 | #define UBLOX_PARSE_TIMEUTC 14 | #define UBLOX_PARSE_POSLLH 15 | //#define UBLOX_PARSE_DOP 16 | #define UBLOX_PARSE_VELNED 17 | //#define UBLOX_PARSE_SVINFO 18 | //#define UBLOX_PARSE_CFGNAV5 19 | //#define UBLOX_PARSE_MONVER 20 | 21 | //-------------------------------------------------------------------- 22 | // Identify the last UBX message in an update interval. 23 | // (There are two parts to a UBX message, the class and the ID.) 24 | // For coherency, you must determine which UBX message is last! 25 | // This section *should* pick the correct last UBX message for NEO-6M devices. 26 | 27 | #define UBX_LAST_MSG_CLASS_IN_INTERVAL ublox::UBX_NAV 28 | 29 | #if defined(UBLOX_PARSE_DOP) 30 | #define UBX_LAST_MSG_ID_IN_INTERVAL ublox::UBX_NAV_DOP 31 | #elif defined(UBLOX_PARSE_VELNED) 32 | #define UBX_LAST_MSG_ID_IN_INTERVAL ublox::UBX_NAV_VELNED 33 | #elif defined(UBLOX_PARSE_POSLLH) 34 | #define UBX_LAST_MSG_ID_IN_INTERVAL ublox::UBX_NAV_POSLLH 35 | #elif defined(UBLOX_PARSE_SVINFO) 36 | #define UBX_LAST_MSG_ID_IN_INTERVAL ublox::UBX_NAV_SVINFO 37 | #else 38 | #define UBX_LAST_MSG_ID_IN_INTERVAL ublox::UBX_NAV_STATUS 39 | #endif 40 | 41 | #endif -------------------------------------------------------------------------------- /Libs/NeoGPS/ublox/ubxmsg.cpp: -------------------------------------------------------------------------------- 1 | #include "ublox/ubxGPS.h" 2 | 3 | // Disable the entire file if derived types are not allowed. 4 | #ifdef NMEAGPS_DERIVED_TYPES 5 | 6 | using namespace ublox; 7 | 8 | bool ublox::configNMEA( ubloxGPS &gps, NMEAGPS::nmea_msg_t msgType, uint8_t rate ) 9 | { 10 | static const ubx_nmea_msg_t ubx[] __PROGMEM = { 11 | #if defined(NMEAGPS_PARSE_GGA) | defined(NMEAGPS_RECOGNIZE_ALL) 12 | UBX_GPGGA, 13 | #endif 14 | 15 | #if defined(NMEAGPS_PARSE_GLL) | defined(NMEAGPS_RECOGNIZE_ALL) 16 | UBX_GPGLL, 17 | #endif 18 | 19 | #if defined(NMEAGPS_PARSE_GSA) | defined(NMEAGPS_RECOGNIZE_ALL) 20 | UBX_GPGSA, 21 | #endif 22 | 23 | #if defined(NMEAGPS_PARSE_GST) | defined(NMEAGPS_RECOGNIZE_ALL) 24 | UBX_GPGST, 25 | #endif 26 | 27 | #if defined(NMEAGPS_PARSE_GSV) | defined(NMEAGPS_RECOGNIZE_ALL) 28 | UBX_GPGSV, 29 | #endif 30 | 31 | #if defined(NMEAGPS_PARSE_RMC) | defined(NMEAGPS_RECOGNIZE_ALL) 32 | UBX_GPRMC, 33 | #endif 34 | 35 | #if defined(NMEAGPS_PARSE_VTG) | defined(NMEAGPS_RECOGNIZE_ALL) 36 | UBX_GPVTG, 37 | #endif 38 | 39 | #if defined(NMEAGPS_PARSE_ZDA) | defined(NMEAGPS_RECOGNIZE_ALL) 40 | UBX_GPZDA, 41 | #endif 42 | }; 43 | 44 | uint8_t msg_index = (uint8_t) msgType - (uint8_t) NMEAGPS::NMEA_FIRST_MSG; 45 | 46 | if (msg_index >= sizeof(ubx)/sizeof(ubx[0])) 47 | return false; 48 | 49 | msg_id_t msg_id = (msg_id_t) pgm_read_byte( &ubx[msg_index] ); 50 | 51 | return gps.send( cfg_msg_t( UBX_NMEA, msg_id, rate ) ); 52 | } 53 | 54 | #endif -------------------------------------------------------------------------------- /Libs/SdFat/BlockDriver.h: -------------------------------------------------------------------------------- 1 | /* Arduino SdFat Library 2 | * Copyright (C) 2016 by William Greiman 3 | * 4 | * This file is part of the Arduino SdFat Library 5 | * 6 | * This Library is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This Library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with the Arduino SdFat Library. If not, see 18 | * . 19 | */ 20 | /** 21 | * \file 22 | * \brief Define block driver. 23 | */ 24 | #ifndef BlockDriver_h 25 | #define BlockDriver_h 26 | #include "FatLib/BaseBlockDriver.h" 27 | #include "SdCard/SdSpiCard.h" 28 | //----------------------------------------------------------------------------- 29 | /** typedef for BlockDriver */ 30 | #if ENABLE_EXTENDED_TRANSFER_CLASS || ENABLE_SDIO_CLASS 31 | typedef BaseBlockDriver BlockDriver; 32 | #else // ENABLE_EXTENDED_TRANSFER_CLASS || ENABLE_SDIO_CLASS 33 | typedef SdSpiCard BlockDriver; 34 | #endif // ENABLE_EXTENDED_TRANSFER_CLASS || ENABLE_SDIO_CLASS 35 | #endif // BlockDriver_h 36 | -------------------------------------------------------------------------------- /Libs/SdFat/FatLib/BaseBlockDriver.h: -------------------------------------------------------------------------------- 1 | /* FatLib Library 2 | * Copyright (C) 2016 by William Greiman 3 | * 4 | * This file is part of the FatLib Library 5 | * 6 | * This Library is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This Library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with the FatLib Library. If not, see 18 | * . 19 | */ 20 | #ifndef BaseBlockDriver_h 21 | #define BaseBlockDriver_h 22 | #include "FatLibConfig.h" 23 | /** 24 | * \class BaseBlockDriver 25 | * \brief Base block driver. 26 | */ 27 | class BaseBlockDriver { 28 | public: 29 | /** 30 | * Read a 512 byte block from an SD card. 31 | * 32 | * \param[in] block Logical block to be read. 33 | * \param[out] dst Pointer to the location that will receive the data. 34 | * \return The value true is returned for success and 35 | * the value false is returned for failure. 36 | */ 37 | virtual bool readBlock(uint32_t block, uint8_t* dst) = 0; 38 | /** End multi-block transfer and go to idle state. 39 | * \return The value true is returned for success and 40 | * the value false is returned for failure. 41 | */ 42 | virtual bool syncBlocks() = 0; 43 | /** 44 | * Writes a 512 byte block to an SD card. 45 | * 46 | * \param[in] block Logical block to be written. 47 | * \param[in] src Pointer to the location of the data to be written. 48 | * \return The value true is returned for success and 49 | * the value false is returned for failure. 50 | */ 51 | virtual bool writeBlock(uint32_t block, const uint8_t* src) = 0; 52 | #if USE_MULTI_BLOCK_IO 53 | /** 54 | * Read multiple 512 byte blocks from an SD card. 55 | * 56 | * \param[in] block Logical block to be read. 57 | * \param[in] nb Number of blocks to be read. 58 | * \param[out] dst Pointer to the location that will receive the data. 59 | * \return The value true is returned for success and 60 | * the value false is returned for failure. 61 | */ 62 | virtual bool readBlocks(uint32_t block, uint8_t* dst, size_t nb) = 0; 63 | /** 64 | * Write multiple 512 byte blocks to an SD card. 65 | * 66 | * \param[in] block Logical block to be written. 67 | * \param[in] nb Number of blocks to be written. 68 | * \param[in] src Pointer to the location of the data to be written. 69 | * \return The value true is returned for success and 70 | * the value false is returned for failure. 71 | */ 72 | virtual bool writeBlocks(uint32_t block, const uint8_t* src, size_t nb) = 0; 73 | #endif // USE_MULTI_BLOCK_IO 74 | }; 75 | #endif // BaseBlockDriver_h 76 | -------------------------------------------------------------------------------- /Libs/SdFat/FatLib/FatApiConstants.h: -------------------------------------------------------------------------------- 1 | /* FatLib Library 2 | * Copyright (C) 2013 by William Greiman 3 | * 4 | * This file is part of the FatLib Library 5 | * 6 | * This Library is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This Library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with the FatLib Library. If not, see 18 | * . 19 | */ 20 | #ifndef FatApiConstants_h 21 | #define FatApiConstants_h 22 | //------------------------------------------------------------------------------ 23 | // use the gnu style oflag in open() 24 | /** open() oflag for reading */ 25 | const uint8_t O_READ = 0X01; 26 | /** open() oflag - same as O_IN */ 27 | const uint8_t O_RDONLY = O_READ; 28 | /** open() oflag for write */ 29 | const uint8_t O_WRITE = 0X02; 30 | /** open() oflag - same as O_WRITE */ 31 | const uint8_t O_WRONLY = O_WRITE; 32 | /** open() oflag for reading and writing */ 33 | const uint8_t O_RDWR = (O_READ | O_WRITE); 34 | /** open() oflag mask for access modes */ 35 | const uint8_t O_ACCMODE = (O_READ | O_WRITE); 36 | /** The file offset shall be set to the end of the file prior to each write. */ 37 | const uint8_t O_APPEND = 0X04; 38 | /** synchronous writes - call sync() after each write */ 39 | const uint8_t O_SYNC = 0X08; 40 | /** truncate the file to zero length */ 41 | const uint8_t O_TRUNC = 0X10; 42 | /** set the initial position at the end of the file */ 43 | const uint8_t O_AT_END = 0X20; 44 | /** create the file if nonexistent */ 45 | const uint8_t O_CREAT = 0X40; 46 | /** If O_CREAT and O_EXCL are set, open() shall fail if the file exists */ 47 | const uint8_t O_EXCL = 0X80; 48 | 49 | // FatFile class static and const definitions 50 | // flags for ls() 51 | /** ls() flag for list all files including hidden. */ 52 | const uint8_t LS_A = 1; 53 | /** ls() flag to print modify. date */ 54 | const uint8_t LS_DATE = 2; 55 | /** ls() flag to print file size. */ 56 | const uint8_t LS_SIZE = 4; 57 | /** ls() flag for recursive list of subdirectories */ 58 | const uint8_t LS_R = 8; 59 | 60 | // flags for timestamp 61 | /** set the file's last access date */ 62 | const uint8_t T_ACCESS = 1; 63 | /** set the file's creation date and time */ 64 | const uint8_t T_CREATE = 2; 65 | /** Set the file's write date and time */ 66 | const uint8_t T_WRITE = 4; 67 | #endif // FatApiConstants_h 68 | -------------------------------------------------------------------------------- /Libs/SdFat/FatLib/FatLib.h: -------------------------------------------------------------------------------- 1 | /* FatLib Library 2 | * Copyright (C) 2013 by William Greiman 3 | * 4 | * This file is part of the FatLib Library 5 | * 6 | * This Library is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This Library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with the FatLib Library. If not, see 18 | * . 19 | */ 20 | #ifndef FatLib_h 21 | #define FatLib_h 22 | #include "ArduinoFiles.h" 23 | #include "ArduinoStream.h" 24 | #include "FatFileSystem.h" 25 | #include "FatLibConfig.h" 26 | #include "FatVolume.h" 27 | #include "FatFile.h" 28 | #include "StdioStream.h" 29 | #include "fstream.h" 30 | //------------------------------------------------------------------------------ 31 | /** FatFileSystem version YYYYMMDD */ 32 | #define FAT_LIB_VERSION 20150131 33 | #endif // FatLib_h 34 | -------------------------------------------------------------------------------- /Libs/SdFat/FatLib/FmtNumber.h: -------------------------------------------------------------------------------- 1 | /* FatLib Library 2 | * Copyright (C) 2013 by William Greiman 3 | * 4 | * This file is part of the FatLib Library 5 | * 6 | * This Library is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This Library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with the FatLib Library. If not, see 18 | * . 19 | */ 20 | #ifndef FmtNumber_h 21 | #define FmtNumber_h 22 | // #include 23 | inline bool isDigit(char c) { 24 | return '0' <= c && c <= '9'; 25 | } 26 | inline bool isSpace(char c) { 27 | return c == ' ' || (0X9 <= c && c <= 0XD); 28 | } 29 | #include 30 | #include 31 | char* fmtDec(uint16_t n, char* p); 32 | char* fmtDec(uint32_t n, char* p); 33 | char* fmtFloat(float value, char* p, uint8_t prec); 34 | char* fmtFloat(float value, char* ptr, uint8_t prec, char expChar); 35 | char* fmtHex(uint32_t n, char* p); 36 | float scale10(float v, int8_t n); 37 | float scanFloat(const char* str, char** ptr); 38 | #endif // FmtNumber_h 39 | -------------------------------------------------------------------------------- /Libs/SdFat/FreeStack.h: -------------------------------------------------------------------------------- 1 | /* Arduino SdFat Library 2 | * Copyright (C) 2015 by William Greiman 3 | * 4 | * This file is part of the Arduino SdFat Library 5 | * 6 | * This Library is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This Library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | 16 | * You should have received a copy of the GNU General Public License 17 | * along with the Arduino SdFat Library. If not, see 18 | * . 19 | */ 20 | #ifndef FreeStack_h 21 | #define FreeStack_h 22 | /** 23 | * \file 24 | * \brief FreeStack() function. 25 | */ 26 | #if defined(__AVR__) || defined(DOXYGEN) 27 | /** boundary between stack and heap. */ 28 | extern char *__brkval; 29 | /** End of bss section.*/ 30 | extern char __bss_end; 31 | /** Amount of free stack space. 32 | * \return The number of free bytes. 33 | */ 34 | static int FreeStack() { 35 | char* sp = reinterpret_cast(SP); 36 | return __brkval ? sp - __brkval : sp - &__bss_end; 37 | // char top; 38 | // return __brkval ? &top - __brkval : &top - &__bss_end; 39 | } 40 | #elif defined(PLATFORM_ID) // Particle board 41 | static int FreeStack() { 42 | return System.freeMemory(); 43 | } 44 | #elif defined(__arm__) 45 | extern "C" char* sbrk(int incr); 46 | static int FreeStack() { 47 | char top = 't'; 48 | return &top - reinterpret_cast(sbrk(0)); 49 | } 50 | #else 51 | #warning FreeStack is not defined for this system. 52 | static int FreeStack() { 53 | return 0; 54 | } 55 | #endif 56 | #endif // FreeStack_h 57 | -------------------------------------------------------------------------------- /Libs/SdFat/MinimumSerial.cpp: -------------------------------------------------------------------------------- 1 | /* Arduino SdFat Library 2 | * Copyright (C) 2012 by William Greiman 3 | * 4 | * This file is part of the Arduino SdFat Library 5 | * 6 | * This Library is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This Library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with the Arduino SdFat Library. If not, see 18 | * . 19 | */ 20 | #include "SysCall.h" 21 | #if defined(UDR0) || defined(DOXYGEN) 22 | #include "MinimumSerial.h" 23 | const uint16_t MIN_2X_BAUD = F_CPU/(4*(2*0XFFF + 1)) + 1; 24 | //------------------------------------------------------------------------------ 25 | int MinimumSerial::available() { 26 | return UCSR0A & (1 << RXC0) ? 1 : 0; 27 | } 28 | //------------------------------------------------------------------------------ 29 | void MinimumSerial::begin(uint32_t baud) { 30 | uint16_t baud_setting; 31 | // don't worry, the compiler will squeeze out F_CPU != 16000000UL 32 | if ((F_CPU != 16000000UL || baud != 57600) && baud > MIN_2X_BAUD) { 33 | // Double the USART Transmission Speed 34 | UCSR0A = 1 << U2X0; 35 | baud_setting = (F_CPU / 4 / baud - 1) / 2; 36 | } else { 37 | // hardcoded exception for compatibility with the bootloader shipped 38 | // with the Duemilanove and previous boards and the firmware on the 8U2 39 | // on the Uno and Mega 2560. 40 | UCSR0A = 0; 41 | baud_setting = (F_CPU / 8 / baud - 1) / 2; 42 | } 43 | // assign the baud_setting 44 | UBRR0H = baud_setting >> 8; 45 | UBRR0L = baud_setting; 46 | // enable transmit and receive 47 | UCSR0B |= (1 << TXEN0) | (1 << RXEN0); 48 | } 49 | //------------------------------------------------------------------------------ 50 | void MinimumSerial::flush() { 51 | while (((1 << UDRIE0) & UCSR0B) || !(UCSR0A & (1 << UDRE0))) {} 52 | } 53 | //------------------------------------------------------------------------------ 54 | int MinimumSerial::read() { 55 | if (UCSR0A & (1 << RXC0)) { 56 | return UDR0; 57 | } 58 | return -1; 59 | } 60 | //------------------------------------------------------------------------------ 61 | size_t MinimumSerial::write(uint8_t b) { 62 | while (((1 << UDRIE0) & UCSR0B) || !(UCSR0A & (1 << UDRE0))) {} 63 | UDR0 = b; 64 | return 1; 65 | } 66 | #endif // defined(UDR0) || defined(DOXYGEN) 67 | -------------------------------------------------------------------------------- /Libs/SdFat/MinimumSerial.h: -------------------------------------------------------------------------------- 1 | /* Arduino SdFat Library 2 | * Copyright (C) 2012 by William Greiman 3 | * 4 | * This file is part of the Arduino SdFat Library 5 | * 6 | * This Library is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This Library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with the Arduino SdFat Library. If not, see 18 | * . 19 | */ 20 | /** 21 | * \file 22 | * \brief Minimal AVR Serial driver. 23 | */ 24 | #ifndef MinimumSerial_h 25 | #define MinimumSerial_h 26 | #include "SysCall.h" 27 | //============================================================================== 28 | /** 29 | * \class MinimumSerial 30 | * \brief mini serial class for the %SdFat library. 31 | */ 32 | class MinimumSerial : public Print { 33 | public: 34 | /** \return true for hardware serial */ 35 | operator bool() { return true; } 36 | /** 37 | * \return one if data is available. 38 | */ 39 | int available(); 40 | /** 41 | * Set baud rate for serial port zero and enable in non interrupt mode. 42 | * Do not call this function if you use another serial library. 43 | * \param[in] baud rate 44 | */ 45 | void begin(uint32_t baud); 46 | /** Wait for write done. */ 47 | void flush(); 48 | /** 49 | * Unbuffered read 50 | * \return -1 if no character is available or an available character. 51 | */ 52 | int read(); 53 | /** 54 | * Unbuffered write 55 | * 56 | * \param[in] b byte to write. 57 | * \return 1 58 | */ 59 | size_t write(uint8_t b); 60 | using Print::write; 61 | }; 62 | #endif // MinimumSerial_h 63 | -------------------------------------------------------------------------------- /Libs/SdFat/SdCard/SdSpiCardEX.cpp: -------------------------------------------------------------------------------- 1 | /* Arduino SdFat Library 2 | * Copyright (C) 2016 by William Greiman 3 | * 4 | * This file is part of the Arduino SdFat Library 5 | * 6 | * This Library is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This Library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with the Arduino SdFat Library. If not, see 18 | * . 19 | */ 20 | #include "SdSpiCard.h" 21 | bool SdSpiCardEX::readBlock(uint32_t block, uint8_t* dst) { 22 | if (m_curState != READ_STATE || block != m_curBlock) { 23 | if (!syncBlocks()) { 24 | return false; 25 | } 26 | if (!SdSpiCard::readStart(block)) { 27 | return false; 28 | } 29 | m_curBlock = block; 30 | m_curState = READ_STATE; 31 | } 32 | if (!SdSpiCard::readData(dst)) { 33 | return false; 34 | } 35 | m_curBlock++; 36 | return true; 37 | } 38 | //----------------------------------------------------------------------------- 39 | bool SdSpiCardEX::readBlocks(uint32_t block, uint8_t* dst, size_t nb) { 40 | for (size_t i = 0; i < nb; i++) { 41 | if (!readBlock(block + i, dst + i*512UL)) { 42 | return false; 43 | } 44 | } 45 | return true; 46 | } 47 | //----------------------------------------------------------------------------- 48 | bool SdSpiCardEX::syncBlocks() { 49 | if (m_curState == READ_STATE) { 50 | m_curState = IDLE_STATE; 51 | if (!SdSpiCard::readStop()) { 52 | return false; 53 | } 54 | } else if (m_curState == WRITE_STATE) { 55 | m_curState = IDLE_STATE; 56 | if (!SdSpiCard::writeStop()) { 57 | return false; 58 | } 59 | } 60 | return true; 61 | } 62 | //----------------------------------------------------------------------------- 63 | bool SdSpiCardEX::writeBlock(uint32_t block, const uint8_t* src) { 64 | if (m_curState != WRITE_STATE || m_curBlock != block) { 65 | if (!syncBlocks()) { 66 | return false; 67 | } 68 | if (!SdSpiCard::writeStart(block)) { 69 | return false; 70 | } 71 | m_curBlock = block; 72 | m_curState = WRITE_STATE; 73 | } 74 | if (!SdSpiCard::writeData(src)) { 75 | return false; 76 | } 77 | m_curBlock++; 78 | return true; 79 | } 80 | //----------------------------------------------------------------------------- 81 | bool SdSpiCardEX::writeBlocks(uint32_t block, 82 | const uint8_t* src, size_t nb) { 83 | for (size_t i = 0; i < nb; i++) { 84 | if (!writeBlock(block + i, src + i*512UL)) { 85 | return false; 86 | } 87 | } 88 | return true; 89 | } 90 | -------------------------------------------------------------------------------- /Libs/SdFat/SdCard/SdioCardEX.cpp: -------------------------------------------------------------------------------- 1 | /* Arduino SdFat Library 2 | * Copyright (C) 2016 by William Greiman 3 | * 4 | * This file is part of the Arduino SdFat Library 5 | * 6 | * This Library is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This Library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with the Arduino SdFat Library. If not, see 18 | * . 19 | */ 20 | #include "SdioCard.h" 21 | 22 | // limit of K66 due to errata KINETIS_K_0N65N. 23 | const uint32_t MAX_SDHC_COUNT = 0XFFFF; 24 | 25 | // Max RU is 1024 blocks. 26 | const uint32_t RU_MASK = 0X03FF; 27 | 28 | bool SdioCardEX::readBlock(uint32_t lba, uint8_t* dst) { 29 | if (m_curState != READ_STATE || lba != m_curLba) { 30 | if (!syncBlocks()) { 31 | return false; 32 | } 33 | m_limitLba = (lba + MAX_SDHC_COUNT) & ~RU_MASK; 34 | if (!SdioCard::readStart(lba, m_limitLba - lba)) { 35 | return false; 36 | } 37 | m_curLba = lba; 38 | m_curState = READ_STATE; 39 | } 40 | if (!SdioCard::readData(dst)) { 41 | return false; 42 | } 43 | m_curLba++; 44 | if (m_curLba >= m_limitLba) { 45 | m_curState = IDLE_STATE; 46 | } 47 | return true; 48 | } 49 | //----------------------------------------------------------------------------- 50 | bool SdioCardEX::readBlocks(uint32_t lba, uint8_t* dst, size_t nb) { 51 | for (size_t i = 0; i < nb; i++) { 52 | if (!readBlock(lba + i, dst + i*512UL)) { 53 | return false; 54 | } 55 | } 56 | return true; 57 | } 58 | //----------------------------------------------------------------------------- 59 | bool SdioCardEX::syncBlocks() { 60 | if (m_curState == READ_STATE) { 61 | m_curState = IDLE_STATE; 62 | if (!SdioCard::readStop()) { 63 | return false; 64 | } 65 | } else if (m_curState == WRITE_STATE) { 66 | m_curState = IDLE_STATE; 67 | if (!SdioCard::writeStop()) { 68 | return false; 69 | } 70 | } 71 | return true; 72 | } 73 | //----------------------------------------------------------------------------- 74 | bool SdioCardEX::writeBlock(uint32_t lba, const uint8_t* src) { 75 | if (m_curState != WRITE_STATE || m_curLba != lba) { 76 | if (!syncBlocks()) { 77 | return false; 78 | } 79 | m_limitLba = (lba + MAX_SDHC_COUNT) & ~RU_MASK; 80 | if (!SdioCard::writeStart(lba , m_limitLba - lba)) { 81 | return false; 82 | } 83 | m_curLba = lba; 84 | m_curState = WRITE_STATE; 85 | } 86 | if (!SdioCard::writeData(src)) { 87 | return false; 88 | } 89 | m_curLba++; 90 | if (m_curLba >= m_limitLba) { 91 | m_curState = IDLE_STATE; 92 | } 93 | return true; 94 | } 95 | //----------------------------------------------------------------------------- 96 | bool SdioCardEX::writeBlocks(uint32_t lba, const uint8_t* src, size_t nb) { 97 | for (size_t i = 0; i < nb; i++) { 98 | if (!writeBlock(lba + i, src + i*512UL)) { 99 | return false; 100 | } 101 | } 102 | return true; 103 | } 104 | -------------------------------------------------------------------------------- /Libs/SdFat/SpiDriver/SdSpiBaseDriver.h: -------------------------------------------------------------------------------- 1 | /* Arduino SdCard Library 2 | * Copyright (C) 2016 by William Greiman 3 | * 4 | * This file is part of the Arduino SdSpiCard Library 5 | * 6 | * This Library is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This Library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with the Arduino SdSpiCard Library. If not, see 18 | * . 19 | */ 20 | #ifndef SdSpiBaseDriver_h 21 | #define SdSpiBaseDriver_h 22 | 23 | // Forward declaration 24 | class SPISettings; 25 | 26 | /** 27 | * \class SdSpiBaseDriver 28 | * \brief SPI base driver. 29 | */ 30 | class SdSpiBaseDriver { 31 | public: 32 | /** Set SPI options for access to SD/SDHC cards. 33 | * 34 | */ 35 | virtual void activate() = 0; 36 | /** Initialize the SPI bus. 37 | * 38 | * \param[in] chipSelectPin SD card chip select pin. 39 | */ 40 | virtual void begin(uint8_t chipSelectPin) = 0; 41 | /** 42 | * End SPI transaction. 43 | */ 44 | virtual void deactivate() = 0; 45 | /** Receive a byte. 46 | * 47 | * \return The byte. 48 | */ 49 | virtual uint8_t receive() = 0; 50 | /** Receive multiple bytes. 51 | * 52 | * \param[out] buf Buffer to receive the data. 53 | * \param[in] n Number of bytes to receive. 54 | * 55 | * \return Zero for no error or nonzero error code. 56 | */ 57 | virtual uint8_t receive(uint8_t* buf, size_t n) = 0; 58 | /** Send a byte. 59 | * 60 | * \param[in] data Byte to send 61 | */ 62 | virtual void send(uint8_t data) = 0; 63 | /** Send multiple bytes. 64 | * 65 | * \param[in] buf Buffer for data to be sent. 66 | * \param[in] n Number of bytes to send. 67 | */ 68 | virtual void send(const uint8_t* buf, size_t n) = 0; 69 | /** Set CS low. */ 70 | virtual void select() = 0; 71 | /** Save SPI settings. 72 | * \param[in] spiSettings SPI speed, mode, and bit order. 73 | */ 74 | virtual void setSpiSettings(const SPISettings & spiSettings) = 0; 75 | /** Set CS high. */ 76 | virtual void unselect() = 0; 77 | }; 78 | #endif // SdSpiBaseDriver_h 79 | -------------------------------------------------------------------------------- /Libs/SdFat/SpiDriver/SdSpiESP8266.cpp: -------------------------------------------------------------------------------- 1 | /* Arduino SdSpiAltDriver Library 2 | * Copyright (C) 2016 by William Greiman 3 | * 4 | * STM32F1 code for Maple and Maple Mini support, 2015 by Victor Perez 5 | * 6 | * This file is part of the Arduino SdSpiAltDriver Library 7 | * 8 | * This Library is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This Library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with the Arduino SdSpiAltDriver Library. If not, see 20 | * . 21 | */ 22 | #if defined(ESP8266) 23 | #include "SdSpiDriver.h" 24 | //------------------------------------------------------------------------------ 25 | /** Initialize the SPI bus. 26 | * 27 | * \param[in] chipSelectPin SD card chip select pin. 28 | */ 29 | void SdSpiAltDriver::begin(uint8_t csPin) { 30 | m_csPin = csPin; 31 | pinMode(m_csPin, OUTPUT); 32 | digitalWrite(m_csPin, HIGH); 33 | SPI.begin(); 34 | } 35 | //------------------------------------------------------------------------------ 36 | /** Set SPI options for access to SD/SDHC cards. 37 | * 38 | */ 39 | void SdSpiAltDriver::activate() { 40 | SPI.beginTransaction(m_spiSettings); 41 | } 42 | //------------------------------------------------------------------------------ 43 | void SdSpiAltDriver::deactivate() { 44 | // Note: endTransaction is an empty function on ESP8266. 45 | SPI.endTransaction(); 46 | } 47 | //------------------------------------------------------------------------------ 48 | /** Receive a byte. 49 | * 50 | * \return The byte. 51 | */ 52 | uint8_t SdSpiAltDriver::receive() { 53 | return SPI.transfer(0XFF); 54 | } 55 | //------------------------------------------------------------------------------ 56 | /** Receive multiple bytes. 57 | * 58 | * \param[out] buf Buffer to receive the data. 59 | * \param[in] n Number of bytes to receive. 60 | * 61 | * \return Zero for no error or nonzero error code. 62 | */ 63 | uint8_t SdSpiAltDriver::receive(uint8_t* buf, size_t n) { 64 | // Works without 32-bit alignment of buf. 65 | SPI.transferBytes(0, buf, n); 66 | return 0; 67 | } 68 | //------------------------------------------------------------------------------ 69 | /** Send a byte. 70 | * 71 | * \param[in] b Byte to send 72 | */ 73 | void SdSpiAltDriver::send(uint8_t b) { 74 | SPI.transfer(b); 75 | } 76 | //------------------------------------------------------------------------------ 77 | /** Send multiple bytes. 78 | * 79 | * \param[in] buf Buffer for data to be sent. 80 | * \param[in] n Number of bytes to send. 81 | */ 82 | void SdSpiAltDriver::send(const uint8_t* buf , size_t n) { 83 | // Adjust to 32-bit alignment. 84 | while ((reinterpret_cast(buf) & 0X3) && n) { 85 | SPI.transfer(*buf++); 86 | n--; 87 | } 88 | SPI.transferBytes(const_cast(buf), 0, n); 89 | } 90 | #endif // defined(ESP8266) 91 | -------------------------------------------------------------------------------- /Libs/SdFat/SpiDriver/boards/AvrDevelopersGpioPinMap.h: -------------------------------------------------------------------------------- 1 | #ifndef AvrDevelopersGpioPinMap_h 2 | #define AvrDevelopersGpioPinMap_h 3 | static const GpioPinMap_t GpioPinMap[] = { 4 | GPIO_PIN(B, 0), // D0 5 | GPIO_PIN(B, 1), // D1 6 | GPIO_PIN(B, 2), // D2 7 | GPIO_PIN(B, 3), // D3 8 | GPIO_PIN(B, 4), // D4 9 | GPIO_PIN(B, 5), // D5 10 | GPIO_PIN(B, 6), // D6 11 | GPIO_PIN(B, 7), // D7 12 | GPIO_PIN(D, 0), // D8 13 | GPIO_PIN(D, 1), // D9 14 | GPIO_PIN(D, 2), // D10 15 | GPIO_PIN(D, 3), // D11 16 | GPIO_PIN(D, 4), // D12 17 | GPIO_PIN(D, 5), // D13 18 | GPIO_PIN(D, 6), // D14 19 | GPIO_PIN(D, 7), // D15 20 | GPIO_PIN(C, 0), // D16 21 | GPIO_PIN(C, 1), // D17 22 | GPIO_PIN(C, 2), // D18 23 | GPIO_PIN(C, 3), // D19 24 | GPIO_PIN(C, 4), // D20 25 | GPIO_PIN(C, 5), // D21 26 | GPIO_PIN(C, 6), // D22 27 | GPIO_PIN(C, 7), // D23 28 | GPIO_PIN(A, 7), // D24 29 | GPIO_PIN(A, 6), // D25 30 | GPIO_PIN(A, 5), // D26 31 | GPIO_PIN(A, 4), // D27 32 | GPIO_PIN(A, 3), // D28 33 | GPIO_PIN(A, 2), // D29 34 | GPIO_PIN(A, 1), // D30 35 | GPIO_PIN(A, 0) // D31 36 | }; 37 | #endif // AvrDevelopersGpioPinMap_h -------------------------------------------------------------------------------- /Libs/SdFat/SpiDriver/boards/BobuinoGpioPinMap.h: -------------------------------------------------------------------------------- 1 | #ifndef BobuinoGpioPinMap_h 2 | #define BobuinoGpioPinMap_h 3 | static const GpioPinMap_t GpioPinMap[] = { 4 | GPIO_PIN(B, 0), // D0 5 | GPIO_PIN(B, 1), // D1 6 | GPIO_PIN(B, 2), // D2 7 | GPIO_PIN(B, 3), // D3 8 | GPIO_PIN(B, 4), // D4 9 | GPIO_PIN(B, 5), // D5 10 | GPIO_PIN(B, 6), // D6 11 | GPIO_PIN(B, 7), // D7 12 | GPIO_PIN(D, 0), // D8 13 | GPIO_PIN(D, 1), // D9 14 | GPIO_PIN(D, 2), // D10 15 | GPIO_PIN(D, 3), // D11 16 | GPIO_PIN(D, 4), // D12 17 | GPIO_PIN(D, 5), // D13 18 | GPIO_PIN(D, 6), // D14 19 | GPIO_PIN(D, 7), // D15 20 | GPIO_PIN(C, 0), // D16 21 | GPIO_PIN(C, 1), // D17 22 | GPIO_PIN(C, 2), // D18 23 | GPIO_PIN(C, 3), // D19 24 | GPIO_PIN(C, 4), // D20 25 | GPIO_PIN(C, 5), // D21 26 | GPIO_PIN(C, 6), // D22 27 | GPIO_PIN(C, 7), // D23 28 | GPIO_PIN(A, 0), // D24 29 | GPIO_PIN(A, 1), // D25 30 | GPIO_PIN(A, 2), // D26 31 | GPIO_PIN(A, 3), // D27 32 | GPIO_PIN(A, 4), // D28 33 | GPIO_PIN(A, 5), // D29 34 | GPIO_PIN(A, 6), // D30 35 | GPIO_PIN(A, 7) // D31 36 | }; 37 | #endif // BobuinoGpioPinMap_h -------------------------------------------------------------------------------- /Libs/SdFat/SpiDriver/boards/GpioPinMap.h: -------------------------------------------------------------------------------- 1 | #ifndef GpioPinMap_h 2 | #define GpioPinMap_h 3 | #if defined(__AVR_ATmega168__)\ 4 | ||defined(__AVR_ATmega168P__)\ 5 | ||defined(__AVR_ATmega328P__) 6 | // 168 and 328 Arduinos 7 | #include "UnoGpioPinMap.h" 8 | #elif defined(__AVR_ATmega1280__)\ 9 | || defined(__AVR_ATmega2560__) 10 | // Mega ADK 11 | #include "MegaGpioPinMap.h" 12 | #elif defined(__AVR_ATmega32U4__) 13 | #ifdef CORE_TEENSY 14 | #include "Teensy2GpioPinMap.h" 15 | #else // CORE_TEENSY 16 | // Leonardo or Yun 17 | #include "LeonardoGpioPinMap.h" 18 | #endif // CORE_TEENSY 19 | #elif defined(__AVR_AT90USB646__)\ 20 | || defined(__AVR_AT90USB1286__) 21 | // Teensy++ 1.0 & 2.0 22 | #include "Teensy2ppGpioPinMap.h" 23 | #elif defined(__AVR_ATmega1284P__)\ 24 | || defined(__AVR_ATmega1284__)\ 25 | || defined(__AVR_ATmega644P__)\ 26 | || defined(__AVR_ATmega644__)\ 27 | || defined(__AVR_ATmega64__)\ 28 | || defined(__AVR_ATmega32__)\ 29 | || defined(__AVR_ATmega324__)\ 30 | || defined(__AVR_ATmega16__) 31 | #ifdef ARDUINO_1284P_AVR_DEVELOPERS 32 | #include "AvrDevelopersGpioPinMap.h" 33 | #elif defined(BOBUINO_PINOUT) || defined(ARDUINO_1284P_BOBUINO) 34 | #include "BobuinoGpioPinMap.h" 35 | #elif defined(ARDUINO_1284P_SLEEPINGBEAUTY) 36 | #include "SleepingBeautyGpioPinMap.h" 37 | #elif defined(STANDARD_PINOUT) || defined(ARDUINO_1284P_STANDARD) 38 | #include "Standard1284GpioPinMap.h" 39 | #else // ARDUINO_1284P_AVR_DEVELOPERS 40 | #error Undefined variant 1284, 644, 324 41 | #endif // ARDUINO_1284P_AVR_DEVELOPERS 42 | #else // 1284P, 1284, 644 43 | #error Unknown board type. 44 | #endif // end all boards 45 | #endif // GpioPinMap_h 46 | -------------------------------------------------------------------------------- /Libs/SdFat/SpiDriver/boards/LeonardoGpioPinMap.h: -------------------------------------------------------------------------------- 1 | #ifndef LeonardoGpioPinMap_h 2 | #define LeonardoGpioPinMap_h 3 | static const GpioPinMap_t GpioPinMap[] = { 4 | GPIO_PIN(D, 2), // D0 5 | GPIO_PIN(D, 3), // D1 6 | GPIO_PIN(D, 1), // D2 7 | GPIO_PIN(D, 0), // D3 8 | GPIO_PIN(D, 4), // D4 9 | GPIO_PIN(C, 6), // D5 10 | GPIO_PIN(D, 7), // D6 11 | GPIO_PIN(E, 6), // D7 12 | GPIO_PIN(B, 4), // D8 13 | GPIO_PIN(B, 5), // D9 14 | GPIO_PIN(B, 6), // D10 15 | GPIO_PIN(B, 7), // D11 16 | GPIO_PIN(D, 6), // D12 17 | GPIO_PIN(C, 7), // D13 18 | GPIO_PIN(B, 3), // D14 19 | GPIO_PIN(B, 1), // D15 20 | GPIO_PIN(B, 2), // D16 21 | GPIO_PIN(B, 0), // D17 22 | GPIO_PIN(F, 7), // D18 23 | GPIO_PIN(F, 6), // D19 24 | GPIO_PIN(F, 5), // D20 25 | GPIO_PIN(F, 4), // D21 26 | GPIO_PIN(F, 1), // D22 27 | GPIO_PIN(F, 0), // D23 28 | GPIO_PIN(D, 4), // D24 29 | GPIO_PIN(D, 7), // D25 30 | GPIO_PIN(B, 4), // D26 31 | GPIO_PIN(B, 5), // D27 32 | GPIO_PIN(B, 6), // D28 33 | GPIO_PIN(D, 6) // D29 34 | }; 35 | #endif // LeonardoGpioPinMap_h 36 | -------------------------------------------------------------------------------- /Libs/SdFat/SpiDriver/boards/MegaGpioPinMap.h: -------------------------------------------------------------------------------- 1 | #ifndef MegaGpioPinMap_h 2 | #define MegaGpioPinMap_h 3 | static const GpioPinMap_t GpioPinMap[] = { 4 | GPIO_PIN(E, 0), // D0 5 | GPIO_PIN(E, 1), // D1 6 | GPIO_PIN(E, 4), // D2 7 | GPIO_PIN(E, 5), // D3 8 | GPIO_PIN(G, 5), // D4 9 | GPIO_PIN(E, 3), // D5 10 | GPIO_PIN(H, 3), // D6 11 | GPIO_PIN(H, 4), // D7 12 | GPIO_PIN(H, 5), // D8 13 | GPIO_PIN(H, 6), // D9 14 | GPIO_PIN(B, 4), // D10 15 | GPIO_PIN(B, 5), // D11 16 | GPIO_PIN(B, 6), // D12 17 | GPIO_PIN(B, 7), // D13 18 | GPIO_PIN(J, 1), // D14 19 | GPIO_PIN(J, 0), // D15 20 | GPIO_PIN(H, 1), // D16 21 | GPIO_PIN(H, 0), // D17 22 | GPIO_PIN(D, 3), // D18 23 | GPIO_PIN(D, 2), // D19 24 | GPIO_PIN(D, 1), // D20 25 | GPIO_PIN(D, 0), // D21 26 | GPIO_PIN(A, 0), // D22 27 | GPIO_PIN(A, 1), // D23 28 | GPIO_PIN(A, 2), // D24 29 | GPIO_PIN(A, 3), // D25 30 | GPIO_PIN(A, 4), // D26 31 | GPIO_PIN(A, 5), // D27 32 | GPIO_PIN(A, 6), // D28 33 | GPIO_PIN(A, 7), // D29 34 | GPIO_PIN(C, 7), // D30 35 | GPIO_PIN(C, 6), // D31 36 | GPIO_PIN(C, 5), // D32 37 | GPIO_PIN(C, 4), // D33 38 | GPIO_PIN(C, 3), // D34 39 | GPIO_PIN(C, 2), // D35 40 | GPIO_PIN(C, 1), // D36 41 | GPIO_PIN(C, 0), // D37 42 | GPIO_PIN(D, 7), // D38 43 | GPIO_PIN(G, 2), // D39 44 | GPIO_PIN(G, 1), // D40 45 | GPIO_PIN(G, 0), // D41 46 | GPIO_PIN(L, 7), // D42 47 | GPIO_PIN(L, 6), // D43 48 | GPIO_PIN(L, 5), // D44 49 | GPIO_PIN(L, 4), // D45 50 | GPIO_PIN(L, 3), // D46 51 | GPIO_PIN(L, 2), // D47 52 | GPIO_PIN(L, 1), // D48 53 | GPIO_PIN(L, 0), // D49 54 | GPIO_PIN(B, 3), // D50 55 | GPIO_PIN(B, 2), // D51 56 | GPIO_PIN(B, 1), // D52 57 | GPIO_PIN(B, 0), // D53 58 | GPIO_PIN(F, 0), // D54 59 | GPIO_PIN(F, 1), // D55 60 | GPIO_PIN(F, 2), // D56 61 | GPIO_PIN(F, 3), // D57 62 | GPIO_PIN(F, 4), // D58 63 | GPIO_PIN(F, 5), // D59 64 | GPIO_PIN(F, 6), // D60 65 | GPIO_PIN(F, 7), // D61 66 | GPIO_PIN(K, 0), // D62 67 | GPIO_PIN(K, 1), // D63 68 | GPIO_PIN(K, 2), // D64 69 | GPIO_PIN(K, 3), // D65 70 | GPIO_PIN(K, 4), // D66 71 | GPIO_PIN(K, 5), // D67 72 | GPIO_PIN(K, 6), // D68 73 | GPIO_PIN(K, 7) // D69 74 | }; 75 | #endif // MegaGpioPinMap_h 76 | -------------------------------------------------------------------------------- /Libs/SdFat/SpiDriver/boards/SleepingBeautyGpioPinMap.h: -------------------------------------------------------------------------------- 1 | #ifndef SleepingBeautyGpioPinMap_h 2 | #define SleepingBeautyGpioPinMap_h 3 | static const GpioPinMap_t GpioPinMap[] = { 4 | GPIO_PIN(D, 0), // D0 5 | GPIO_PIN(D, 1), // D1 6 | GPIO_PIN(D, 2), // D2 7 | GPIO_PIN(D, 3), // D3 8 | GPIO_PIN(B, 0), // D4 9 | GPIO_PIN(B, 1), // D5 10 | GPIO_PIN(B, 2), // D6 11 | GPIO_PIN(B, 3), // D7 12 | GPIO_PIN(D, 6), // D8 13 | GPIO_PIN(D, 5), // D9 14 | GPIO_PIN(B, 4), // D10 15 | GPIO_PIN(B, 5), // D11 16 | GPIO_PIN(B, 6), // D12 17 | GPIO_PIN(B, 7), // D13 18 | GPIO_PIN(C, 7), // D14 19 | GPIO_PIN(C, 6), // D15 20 | GPIO_PIN(A, 5), // D16 21 | GPIO_PIN(A, 4), // D17 22 | GPIO_PIN(A, 3), // D18 23 | GPIO_PIN(A, 2), // D19 24 | GPIO_PIN(A, 1), // D20 25 | GPIO_PIN(A, 0), // D21 26 | GPIO_PIN(D, 4), // D22 27 | GPIO_PIN(D, 7), // D23 28 | GPIO_PIN(C, 2), // D24 29 | GPIO_PIN(C, 3), // D25 30 | GPIO_PIN(C, 4), // D26 31 | GPIO_PIN(C, 5), // D27 32 | GPIO_PIN(C, 1), // D28 33 | GPIO_PIN(C, 0), // D29 34 | GPIO_PIN(A, 6), // D30 35 | GPIO_PIN(A, 7) // D31 36 | }; 37 | #endif // SleepingBeautyGpioPinMap_h -------------------------------------------------------------------------------- /Libs/SdFat/SpiDriver/boards/Standard1284GpioPinMap.h: -------------------------------------------------------------------------------- 1 | #ifndef Standard1284GpioPinMap_h 2 | #define Standard1284GpioPinMap_h 3 | static const GpioPinMap_t GpioPinMap[] = { 4 | GPIO_PIN(B, 0), // D0 5 | GPIO_PIN(B, 1), // D1 6 | GPIO_PIN(B, 2), // D2 7 | GPIO_PIN(B, 3), // D3 8 | GPIO_PIN(B, 4), // D4 9 | GPIO_PIN(B, 5), // D5 10 | GPIO_PIN(B, 6), // D6 11 | GPIO_PIN(B, 7), // D7 12 | GPIO_PIN(D, 0), // D8 13 | GPIO_PIN(D, 1), // D9 14 | GPIO_PIN(D, 2), // D10 15 | GPIO_PIN(D, 3), // D11 16 | GPIO_PIN(D, 4), // D12 17 | GPIO_PIN(D, 5), // D13 18 | GPIO_PIN(D, 6), // D14 19 | GPIO_PIN(D, 7), // D15 20 | GPIO_PIN(C, 0), // D16 21 | GPIO_PIN(C, 1), // D17 22 | GPIO_PIN(C, 2), // D18 23 | GPIO_PIN(C, 3), // D19 24 | GPIO_PIN(C, 4), // D20 25 | GPIO_PIN(C, 5), // D21 26 | GPIO_PIN(C, 6), // D22 27 | GPIO_PIN(C, 7), // D23 28 | GPIO_PIN(A, 0), // D24 29 | GPIO_PIN(A, 1), // D25 30 | GPIO_PIN(A, 2), // D26 31 | GPIO_PIN(A, 3), // D27 32 | GPIO_PIN(A, 4), // D28 33 | GPIO_PIN(A, 5), // D29 34 | GPIO_PIN(A, 6), // D30 35 | GPIO_PIN(A, 7) // D31 36 | }; 37 | #endif // Standard1284GpioPinMap_h -------------------------------------------------------------------------------- /Libs/SdFat/SpiDriver/boards/Teensy2GpioPinMap.h: -------------------------------------------------------------------------------- 1 | #ifndef Teensy2GpioPinMap_h 2 | #define Teensy2GpioPinMap_h 3 | static const GpioPinMap_t GpioPinMap[] = { 4 | GPIO_PIN(B, 0), // D0 5 | GPIO_PIN(B, 1), // D1 6 | GPIO_PIN(B, 2), // D2 7 | GPIO_PIN(B, 3), // D3 8 | GPIO_PIN(B, 7), // D4 9 | GPIO_PIN(D, 0), // D5 10 | GPIO_PIN(D, 1), // D6 11 | GPIO_PIN(D, 2), // D7 12 | GPIO_PIN(D, 3), // D8 13 | GPIO_PIN(C, 6), // D9 14 | GPIO_PIN(C, 7), // D10 15 | GPIO_PIN(D, 6), // D11 16 | GPIO_PIN(D, 7), // D12 17 | GPIO_PIN(B, 4), // D13 18 | GPIO_PIN(B, 5), // D14 19 | GPIO_PIN(B, 6), // D15 20 | GPIO_PIN(F, 7), // D16 21 | GPIO_PIN(F, 6), // D17 22 | GPIO_PIN(F, 5), // D18 23 | GPIO_PIN(F, 4), // D19 24 | GPIO_PIN(F, 1), // D20 25 | GPIO_PIN(F, 0), // D21 26 | GPIO_PIN(D, 4), // D22 27 | GPIO_PIN(D, 5), // D23 28 | GPIO_PIN(E, 6), // D24 29 | }; 30 | #endif // Teensy2GpioPinMap_h 31 | -------------------------------------------------------------------------------- /Libs/SdFat/SpiDriver/boards/Teensy2ppGpioPinMap.h: -------------------------------------------------------------------------------- 1 | #ifndef Teensypp2GpioPinMap_h 2 | #define Teensypp2GpioPinMap_h 3 | static const GpioPinMap_t GpioPinMap[] = { 4 | GPIO_PIN(D, 0), // D0 5 | GPIO_PIN(D, 1), // D1 6 | GPIO_PIN(D, 2), // D2 7 | GPIO_PIN(D, 3), // D3 8 | GPIO_PIN(D, 4), // D4 9 | GPIO_PIN(D, 5), // D5 10 | GPIO_PIN(D, 6), // D6 11 | GPIO_PIN(D, 7), // D7 12 | GPIO_PIN(E, 0), // D8 13 | GPIO_PIN(E, 1), // D9 14 | GPIO_PIN(C, 0), // D10 15 | GPIO_PIN(C, 1), // D11 16 | GPIO_PIN(C, 2), // D12 17 | GPIO_PIN(C, 3), // D13 18 | GPIO_PIN(C, 4), // D14 19 | GPIO_PIN(C, 5), // D15 20 | GPIO_PIN(C, 6), // D16 21 | GPIO_PIN(C, 7), // D17 22 | GPIO_PIN(E, 6), // D18 23 | GPIO_PIN(E, 7), // D19 24 | GPIO_PIN(B, 0), // D20 25 | GPIO_PIN(B, 1), // D21 26 | GPIO_PIN(B, 2), // D22 27 | GPIO_PIN(B, 3), // D23 28 | GPIO_PIN(B, 4), // D24 29 | GPIO_PIN(B, 5), // D25 30 | GPIO_PIN(B, 6), // D26 31 | GPIO_PIN(B, 7), // D27 32 | GPIO_PIN(A, 0), // D28 33 | GPIO_PIN(A, 1), // D29 34 | GPIO_PIN(A, 2), // D30 35 | GPIO_PIN(A, 3), // D31 36 | GPIO_PIN(A, 4), // D32 37 | GPIO_PIN(A, 5), // D33 38 | GPIO_PIN(A, 6), // D34 39 | GPIO_PIN(A, 7), // D35 40 | GPIO_PIN(E, 4), // D36 41 | GPIO_PIN(E, 5), // D37 42 | GPIO_PIN(F, 0), // D38 43 | GPIO_PIN(F, 1), // D39 44 | GPIO_PIN(F, 2), // D40 45 | GPIO_PIN(F, 3), // D41 46 | GPIO_PIN(F, 4), // D42 47 | GPIO_PIN(F, 5), // D43 48 | GPIO_PIN(F, 6), // D44 49 | GPIO_PIN(F, 7), // D45 50 | }; 51 | #endif // Teensypp2GpioPinMap_h 52 | -------------------------------------------------------------------------------- /Libs/SdFat/SpiDriver/boards/UnoGpioPinMap.h: -------------------------------------------------------------------------------- 1 | #ifndef UnoGpioPinMap_h 2 | #define UnoGpioPinMap_h 3 | static const GpioPinMap_t GpioPinMap[] = { 4 | GPIO_PIN(D, 0), // D0 5 | GPIO_PIN(D, 1), // D1 6 | GPIO_PIN(D, 2), // D2 7 | GPIO_PIN(D, 3), // D3 8 | GPIO_PIN(D, 4), // D4 9 | GPIO_PIN(D, 5), // D5 10 | GPIO_PIN(D, 6), // D6 11 | GPIO_PIN(D, 7), // D7 12 | GPIO_PIN(B, 0), // D8 13 | GPIO_PIN(B, 1), // D9 14 | GPIO_PIN(B, 2), // D10 15 | GPIO_PIN(B, 3), // D11 16 | GPIO_PIN(B, 4), // D12 17 | GPIO_PIN(B, 5), // D13 18 | GPIO_PIN(C, 0), // D14 19 | GPIO_PIN(C, 1), // D15 20 | GPIO_PIN(C, 2), // D16 21 | GPIO_PIN(C, 3), // D17 22 | GPIO_PIN(C, 4), // D18 23 | GPIO_PIN(C, 5) // D19 24 | }; 25 | #endif // UnoGpioPinMap_h -------------------------------------------------------------------------------- /Libs/SdFat/SysCall.h: -------------------------------------------------------------------------------- 1 | /* FatLib Library 2 | * Copyright (C) 2013 by William Greiman 3 | * 4 | * This file is part of the FatLib Library 5 | * 6 | * This Library is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This Library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with the FatLib Library. If not, see 18 | * . 19 | */ 20 | #ifndef SysCall_h 21 | #define SysCall_h 22 | /** 23 | * \file 24 | * \brief SysCall class 25 | */ 26 | #if defined(ARDUINO) 27 | #include 28 | #include 29 | #elif defined(PLATFORM_ID) // Only defined if a Particle device 30 | #include "application.h" 31 | #else // defined(ARDUINO) 32 | #error "Unknown system" 33 | #endif // defined(ARDUINO) 34 | //----------------------------------------------------------------------------- 35 | #ifdef ESP8266 36 | // undefine F macro if ESP8266. 37 | #undef F 38 | #endif // ESP8266 39 | //----------------------------------------------------------------------------- 40 | #ifndef F 41 | /** Define macro for strings stored in flash. */ 42 | #define F(str) (str) 43 | #endif // F 44 | //----------------------------------------------------------------------------- 45 | /** \return the time in milliseconds. */ 46 | inline uint16_t curTimeMS() { 47 | return millis(); 48 | } 49 | //----------------------------------------------------------------------------- 50 | /** 51 | * \class SysCall 52 | * \brief SysCall - Class to wrap system calls. 53 | */ 54 | class SysCall { 55 | public: 56 | /** Halt execution of this thread. */ 57 | static void halt() { 58 | while (1) { 59 | yield(); 60 | } 61 | } 62 | /** Yield to other threads. */ 63 | static void yield(); 64 | }; 65 | 66 | #if defined(ESP8266) 67 | inline void SysCall::yield() { 68 | // Avoid ESP8266 bug 69 | delay(0); 70 | } 71 | #elif defined(ARDUINO) 72 | inline void SysCall::yield() { 73 | // Use the external Arduino yield() function. 74 | ::yield(); 75 | } 76 | #elif defined(PLATFORM_ID) // Only defined if a Particle device 77 | inline void SysCall::yield() { 78 | Particle.process(); 79 | } 80 | #else // ESP8266 81 | inline void SysCall::yield() {} 82 | #endif // ESP8266 83 | #endif // SysCall_h 84 | -------------------------------------------------------------------------------- /Libs/USB/Core/usbd_ctlreq.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usbd_req.h 4 | * @author MCD Application Team 5 | * @version V2.4.2 6 | * @date 11-December-2015 7 | * @brief Header file for the usbd_req.c file 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2015 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | /* Define to prevent recursive inclusion -------------------------------------*/ 29 | #ifndef __USB_REQUEST_H 30 | #define __USB_REQUEST_H 31 | 32 | #ifdef __cplusplus 33 | extern "C" { 34 | #endif 35 | 36 | /* Includes ------------------------------------------------------------------*/ 37 | #include "usbd_def.h" 38 | 39 | 40 | /** @addtogroup STM32_USB_DEVICE_LIBRARY 41 | * @{ 42 | */ 43 | 44 | /** @defgroup USBD_REQ 45 | * @brief header file for the usbd_req.c file 46 | * @{ 47 | */ 48 | 49 | /** @defgroup USBD_REQ_Exported_Defines 50 | * @{ 51 | */ 52 | /** 53 | * @} 54 | */ 55 | 56 | 57 | /** @defgroup USBD_REQ_Exported_Types 58 | * @{ 59 | */ 60 | /** 61 | * @} 62 | */ 63 | 64 | 65 | 66 | /** @defgroup USBD_REQ_Exported_Macros 67 | * @{ 68 | */ 69 | /** 70 | * @} 71 | */ 72 | 73 | /** @defgroup USBD_REQ_Exported_Variables 74 | * @{ 75 | */ 76 | /** 77 | * @} 78 | */ 79 | 80 | /** @defgroup USBD_REQ_Exported_FunctionsPrototype 81 | * @{ 82 | */ 83 | 84 | USBD_StatusTypeDef USBD_StdDevReq (USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req); 85 | USBD_StatusTypeDef USBD_StdItfReq (USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req); 86 | USBD_StatusTypeDef USBD_StdEPReq (USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req); 87 | 88 | 89 | void USBD_CtlError (USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req); 90 | 91 | void USBD_ParseSetupRequest (USBD_SetupReqTypedef *req, uint8_t *pdata); 92 | 93 | void USBD_GetString (const char *desc, uint8_t *unicode, uint16_t *len); 94 | /** 95 | * @} 96 | */ 97 | 98 | #ifdef __cplusplus 99 | } 100 | #endif 101 | 102 | #endif /* __USB_REQUEST_H */ 103 | 104 | /** 105 | * @} 106 | */ 107 | 108 | /** 109 | * @} 110 | */ 111 | 112 | 113 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 114 | -------------------------------------------------------------------------------- /Libs/USB/Core/usbd_ioreq.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usbd_ioreq.h 4 | * @author MCD Application Team 5 | * @version V2.4.2 6 | * @date 11-December-2015 7 | * @brief Header file for the usbd_ioreq.c file 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2015 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | /* Define to prevent recursive inclusion -------------------------------------*/ 29 | #ifndef __USBD_IOREQ_H 30 | #define __USBD_IOREQ_H 31 | 32 | #ifdef __cplusplus 33 | extern "C" { 34 | #endif 35 | 36 | /* Includes ------------------------------------------------------------------*/ 37 | #include "usbd_def.h" 38 | #include "usbd_core.h" 39 | 40 | /** @addtogroup STM32_USB_DEVICE_LIBRARY 41 | * @{ 42 | */ 43 | 44 | /** @defgroup USBD_IOREQ 45 | * @brief header file for the usbd_ioreq.c file 46 | * @{ 47 | */ 48 | 49 | /** @defgroup USBD_IOREQ_Exported_Defines 50 | * @{ 51 | */ 52 | /** 53 | * @} 54 | */ 55 | 56 | 57 | /** @defgroup USBD_IOREQ_Exported_Types 58 | * @{ 59 | */ 60 | 61 | 62 | /** 63 | * @} 64 | */ 65 | 66 | 67 | 68 | /** @defgroup USBD_IOREQ_Exported_Macros 69 | * @{ 70 | */ 71 | 72 | /** 73 | * @} 74 | */ 75 | 76 | /** @defgroup USBD_IOREQ_Exported_Variables 77 | * @{ 78 | */ 79 | 80 | /** 81 | * @} 82 | */ 83 | 84 | /** @defgroup USBD_IOREQ_Exported_FunctionsPrototype 85 | * @{ 86 | */ 87 | 88 | USBD_StatusTypeDef USBD_CtlSendData (USBD_HandleTypeDef *pdev, 89 | const uint8_t *buf, 90 | uint16_t len); 91 | 92 | USBD_StatusTypeDef USBD_CtlContinueSendData (USBD_HandleTypeDef *pdev, 93 | uint8_t *pbuf, 94 | uint16_t len); 95 | 96 | USBD_StatusTypeDef USBD_CtlPrepareRx (USBD_HandleTypeDef *pdev, 97 | uint8_t *pbuf, 98 | uint16_t len); 99 | 100 | USBD_StatusTypeDef USBD_CtlContinueRx (USBD_HandleTypeDef *pdev, 101 | uint8_t *pbuf, 102 | uint16_t len); 103 | 104 | USBD_StatusTypeDef USBD_CtlSendStatus (USBD_HandleTypeDef *pdev); 105 | 106 | USBD_StatusTypeDef USBD_CtlReceiveStatus (USBD_HandleTypeDef *pdev); 107 | 108 | uint16_t USBD_GetRxCount (USBD_HandleTypeDef *pdev , 109 | uint8_t epnum); 110 | 111 | /** 112 | * @} 113 | */ 114 | 115 | #ifdef __cplusplus 116 | } 117 | #endif 118 | 119 | #endif /* __USBD_IOREQ_H */ 120 | 121 | /** 122 | * @} 123 | */ 124 | 125 | /** 126 | * @} 127 | */ 128 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 129 | -------------------------------------------------------------------------------- /Libs/USB/MSC/usbd_msc_data.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usbd_msc_data.c 4 | * @author MCD Application Team 5 | * @version V2.4.2 6 | * @date 11-December-2015 7 | * @brief This file provides all the vital inquiry pages and sense data. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2015 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | /* Includes ------------------------------------------------------------------*/ 29 | #include "usbd_msc_data.h" 30 | 31 | 32 | /** @addtogroup STM32_USB_DEVICE_LIBRARY 33 | * @{ 34 | */ 35 | 36 | 37 | /** @defgroup MSC_DATA 38 | * @brief Mass storage info/data module 39 | * @{ 40 | */ 41 | 42 | /** @defgroup MSC_DATA_Private_TypesDefinitions 43 | * @{ 44 | */ 45 | /** 46 | * @} 47 | */ 48 | 49 | 50 | /** @defgroup MSC_DATA_Private_Defines 51 | * @{ 52 | */ 53 | /** 54 | * @} 55 | */ 56 | 57 | 58 | /** @defgroup MSC_DATA_Private_Macros 59 | * @{ 60 | */ 61 | /** 62 | * @} 63 | */ 64 | 65 | 66 | /** @defgroup MSC_DATA_Private_Variables 67 | * @{ 68 | */ 69 | 70 | 71 | /* USB Mass storage Page 0 Inquiry Data */ 72 | const uint8_t MSC_Page00_Inquiry_Data[] = {//7 73 | 0x00, 74 | 0x00, 75 | 0x00, 76 | (LENGTH_INQUIRY_PAGE00 - 4), 77 | 0x00, 78 | 0x80, 79 | 0x83 80 | }; 81 | /* USB Mass storage sense 6 Data */ 82 | const uint8_t MSC_Mode_Sense6_data[] = { 83 | 0x00, 84 | 0x00, 85 | 0x00, 86 | 0x00, 87 | 0x00, 88 | 0x00, 89 | 0x00, 90 | 0x00 91 | }; 92 | /* USB Mass storage sense 10 Data */ 93 | const uint8_t MSC_Mode_Sense10_data[] = { 94 | 0x00, 95 | 0x06, 96 | 0x00, 97 | 0x00, 98 | 0x00, 99 | 0x00, 100 | 0x00, 101 | 0x00 102 | }; 103 | /** 104 | * @} 105 | */ 106 | 107 | 108 | /** @defgroup MSC_DATA_Private_FunctionPrototypes 109 | * @{ 110 | */ 111 | /** 112 | * @} 113 | */ 114 | 115 | 116 | /** @defgroup MSC_DATA_Private_Functions 117 | * @{ 118 | */ 119 | 120 | /** 121 | * @} 122 | */ 123 | 124 | 125 | /** 126 | * @} 127 | */ 128 | 129 | 130 | /** 131 | * @} 132 | */ 133 | 134 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 135 | -------------------------------------------------------------------------------- /Libs/USB/MSC/usbd_msc_data.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usbd_msc_data.h 4 | * @author MCD Application Team 5 | * @version V2.4.2 6 | * @date 11-December-2015 7 | * @brief Header for the usbd_msc_data.c file 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2015 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | /* Define to prevent recursive inclusion -------------------------------------*/ 29 | #ifndef __USBD_MSC_DATA_H 30 | #define __USBD_MSC_DATA_H 31 | 32 | #ifdef __cplusplus 33 | extern "C" { 34 | #endif 35 | 36 | /* Includes ------------------------------------------------------------------*/ 37 | #include "usbd_conf.h" 38 | 39 | /** @addtogroup STM32_USB_DEVICE_LIBRARY 40 | * @{ 41 | */ 42 | 43 | /** @defgroup USB_INFO 44 | * @brief general defines for the usb device library file 45 | * @{ 46 | */ 47 | 48 | /** @defgroup USB_INFO_Exported_Defines 49 | * @{ 50 | */ 51 | #define MODE_SENSE6_LEN 8 52 | #define MODE_SENSE10_LEN 8 53 | #define LENGTH_INQUIRY_PAGE00 7 54 | #define LENGTH_FORMAT_CAPACITIES 20 55 | 56 | /** 57 | * @} 58 | */ 59 | 60 | 61 | /** @defgroup USBD_INFO_Exported_TypesDefinitions 62 | * @{ 63 | */ 64 | /** 65 | * @} 66 | */ 67 | 68 | 69 | 70 | /** @defgroup USBD_INFO_Exported_Macros 71 | * @{ 72 | */ 73 | 74 | /** 75 | * @} 76 | */ 77 | 78 | /** @defgroup USBD_INFO_Exported_Variables 79 | * @{ 80 | */ 81 | extern const uint8_t MSC_Page00_Inquiry_Data[]; 82 | extern const uint8_t MSC_Mode_Sense6_data[]; 83 | extern const uint8_t MSC_Mode_Sense10_data[] ; 84 | 85 | /** 86 | * @} 87 | */ 88 | 89 | /** @defgroup USBD_INFO_Exported_FunctionsPrototype 90 | * @{ 91 | */ 92 | 93 | /** 94 | * @} 95 | */ 96 | 97 | #ifdef __cplusplus 98 | } 99 | #endif 100 | 101 | #endif /* __USBD_MSC_DATA_H */ 102 | 103 | /** 104 | * @} 105 | */ 106 | 107 | /** 108 | * @} 109 | */ 110 | 111 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 112 | -------------------------------------------------------------------------------- /Libs/USB/MSC_CDC/usbd_msc_cdc.h: -------------------------------------------------------------------------------- 1 | 2 | /* Define to prevent recursive inclusion -------------------------------------*/ 3 | #ifndef __USB_MSC_CDC_CORE_H 4 | #define __USB_MSC_CDC_CORE_H 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | /* Includes ------------------------------------------------------------------*/ 11 | #include "usbd_ioreq.h" 12 | 13 | /** @addtogroup STM32_USB_DEVICE_LIBRARY 14 | * @{ 15 | */ 16 | 17 | 18 | /** @defgroup USBD_MSC_CDC_Exported_Defines 19 | * @{ 20 | */ 21 | //#define TEMPLATE_EPIN_ADDR 0x81 22 | //#define TEMPLATE_EPIN_SIZE 0x10 23 | 24 | /** 25 | * @} 26 | */ 27 | 28 | 29 | /** @defgroup USBD_CORE_Exported_TypesDefinitions 30 | * @{ 31 | */ 32 | 33 | /** 34 | * @} 35 | */ 36 | 37 | 38 | 39 | /** @defgroup USBD_CORE_Exported_Macros 40 | * @{ 41 | */ 42 | 43 | /** 44 | * @} 45 | */ 46 | 47 | /** @defgroup USBD_CORE_Exported_Variables 48 | * @{ 49 | */ 50 | 51 | extern USBD_ClassTypeDef USBD_MSC_CDC_ClassDriver; 52 | /** 53 | * @} 54 | */ 55 | 56 | /** @defgroup USB_CORE_Exported_Functions 57 | * @{ 58 | */ 59 | /** 60 | * @} 61 | */ 62 | 63 | #ifdef __cplusplus 64 | } 65 | #endif 66 | 67 | #endif /* __USB_MSC_CDC_CORE_H */ 68 | /** 69 | * @} 70 | */ 71 | 72 | /** 73 | * @} 74 | */ 75 | -------------------------------------------------------------------------------- /Scripts/dump_firmware.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | import re 4 | 5 | def main(): 6 | if len(sys.argv) < 2: 7 | print("Usage: dump_firmware.py ") 8 | exit(1) 9 | 10 | symb_table_start = re.compile("SYMBOL TABLE:") 11 | symb_table_end = re.compile("^[\\s]*$") 12 | line_re = re.compile("([0-9a-fA-F]+)\\s+[^\\s]+\\s+[^\\s]*\\s*([^\\s]+)\\s+([0-9a-fA-F]+)\\s+(.*)") 13 | 14 | 15 | dump = open(sys.argv[1], "r") 16 | skip = True 17 | items = [] 18 | for line in dump: 19 | if skip and symb_table_start.match(line): 20 | skip = False 21 | elif not skip and symb_table_end.match(line): 22 | skip = True 23 | elif not skip: 24 | m = line_re.match(line) 25 | 26 | item = (int(m.group(1), 16), m.group(1), m.group(2), int(m.group(3), 16), m.group(4)) 27 | items.append(item) 28 | 29 | for item in sorted(items): 30 | print("\"0x" + item[1] + "\"\t" + item[2] + "\t" + str(item[3]) + "\t" + item[4]) 31 | 32 | 33 | 34 | if __name__ == "__main__": 35 | main() -------------------------------------------------------------------------------- /Src/8x12Font.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | extern const GFXfont Monospace8x12Font; -------------------------------------------------------------------------------- /Src/BoardInit.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include "BoardInit.h" 9 | 10 | #include 11 | 12 | // Libc requires _init() to perform some initialization before global constructors run. 13 | // I would love if this symbol is defined as weak in newlib-nano (libc), but it is not. 14 | extern "C" void _init(void) {} 15 | 16 | // Set up board clocks 17 | void SystemClock_Config(void) 18 | { 19 | // Set up external oscillator to 72 MHz 20 | RCC_OscInitTypeDef RCC_OscInitStruct; 21 | RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; 22 | RCC_OscInitStruct.HSEState = RCC_HSE_ON; 23 | RCC_OscInitStruct.LSEState = RCC_LSE_OFF; 24 | RCC_OscInitStruct.HSIState = RCC_HSI_ON; 25 | RCC_OscInitStruct.HSICalibrationValue = 16; 26 | RCC_OscInitStruct.HSEPredivValue = RCC_HSE_PREDIV_DIV1; 27 | RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; 28 | RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; 29 | RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL9; 30 | HAL_RCC_OscConfig(&RCC_OscInitStruct); 31 | 32 | // Set up periperal clocking 33 | RCC_ClkInitTypeDef RCC_ClkInitStruct; 34 | RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK 35 | |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2; 36 | RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; 37 | RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; 38 | RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2; 39 | RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; 40 | HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2); 41 | 42 | // Set up USB clock 43 | RCC_PeriphCLKInitTypeDef PeriphClkInit; 44 | PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USB; 45 | PeriphClkInit.UsbClockSelection = RCC_USBCLKSOURCE_PLL_DIV1_5; 46 | HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit); 47 | 48 | // Set up SysTTick to 1 ms 49 | // TODO: Do we really need this? SysTick is initialized multiple times in HAL 50 | HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/1000); 51 | HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK); 52 | 53 | // SysTick_IRQn interrupt configuration - setting SysTick as lower priority to satisfy FreeRTOS requirements 54 | HAL_NVIC_SetPriority(SysTick_IRQn, 15, 0); 55 | } 56 | 57 | void InitBoard() 58 | { 59 | HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4); 60 | 61 | // Initialize board and HAL 62 | HAL_Init(); 63 | SystemClock_Config(); 64 | } 65 | 66 | extern "C" 67 | { 68 | void SysTick_Handler(void) { 69 | HAL_IncTick(); 70 | HAL_SYSTICK_IRQHandler(); 71 | } 72 | 73 | extern "C" 74 | void Error_Handler() 75 | { 76 | 77 | } 78 | 79 | extern "C" 80 | __attribute__((noreturn)) 81 | void vApplicationStackOverflowHook(xTaskHandle *pxTask, 82 | signed char *pcTaskName) 83 | { 84 | /* This function will get called if a task overflows its stack. 85 | * If the parameters are corrupt then inspect pxCurrentTCB to find 86 | * which was the offending task. */ 87 | 88 | (void) pxTask; 89 | (void) pcTaskName; 90 | 91 | while (1) 92 | ; 93 | } 94 | 95 | extern "C" 96 | __attribute__((noreturn)) 97 | void vApplicationMallocFailedHook( void ) 98 | { 99 | /* vApplicationMallocFailedHook() will only be called if 100 | configUSE_MALLOC_FAILED_HOOK is set to 1 in FreeRTOSConfig.h. It is a hook 101 | function that will get called if a call to pvPortMalloc() fails.*/ 102 | //taskDISABLE_INTERRUPTS(); 103 | for( ;; ); 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /Src/BoardInit.h: -------------------------------------------------------------------------------- 1 | #ifndef BOARDINIT_H 2 | #define BOARDINIT_H 3 | 4 | void InitBoard(); 5 | 6 | #endif // BOARDINIT_H 7 | -------------------------------------------------------------------------------- /Src/ButtonsThread.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "ButtonsThread.h" 4 | #include "FreeRTOSHelpers.h" 5 | 6 | #include "USBDebugLogger.h" 7 | 8 | #include 9 | 10 | // TODO: perhaps it would be reasonable to detect button press via pin change interrupt 11 | 12 | // Pins assignment 13 | static GPIO_TypeDef * const BUTTONS_PORT = GPIOB; 14 | const uint32_t SEL_BUTTON_PIN = LL_GPIO_PIN_12; 15 | const uint32_t OK_BUTTON_PIN = LL_GPIO_PIN_13; 16 | 17 | // Timing constants 18 | const uint32_t DEBOUNCE_DURATION = 1 / portTICK_PERIOD_MS; 19 | const uint32_t LONG_PRESS_DURATION = 500 / portTICK_PERIOD_MS; 20 | const uint32_t VERY_LONG_PRESS_DURATION = 1000 / portTICK_PERIOD_MS; 21 | const uint32_t POWER_OFF_POLL_PERIOD = 1000 / portTICK_PERIOD_MS; // Polling very rare when power is off 22 | const uint32_t IDLE_POLL_PERIOD = 100 / portTICK_PERIOD_MS; // And little more frequent if we are on 23 | const uint32_t ACTIVE_POLL_PERIOD = 10 / portTICK_PERIOD_MS; // And very often when user actively pressing buttons 24 | 25 | static Queue buttonsQueue; // 3 clicks more than enough 26 | 27 | 28 | // Initialize buttons related stuff 29 | void initButtons() 30 | { 31 | //enable clock to the GPIOB peripheral 32 | __HAL_RCC_GPIOB_CLK_ENABLE(); 33 | 34 | // Set up button pins 35 | LL_GPIO_SetPinMode(BUTTONS_PORT, SEL_BUTTON_PIN, LL_GPIO_MODE_FLOATING); 36 | LL_GPIO_SetPinMode(BUTTONS_PORT, OK_BUTTON_PIN, LL_GPIO_MODE_INPUT); 37 | LL_GPIO_SetPinPull(BUTTONS_PORT, OK_BUTTON_PIN, LL_GPIO_PULL_DOWN); 38 | } 39 | 40 | 41 | // Reading button state (perform debounce first) 42 | inline bool getButtonState(uint32_t pin) 43 | { 44 | if(LL_GPIO_IsInputPinSet(BUTTONS_PORT, pin)) 45 | { 46 | // dobouncing 47 | vTaskDelay(DEBOUNCE_DURATION); 48 | if(LL_GPIO_IsInputPinSet(BUTTONS_PORT, pin)) 49 | return true; 50 | } 51 | 52 | return false; 53 | } 54 | 55 | 56 | /// Return ID of the pressed button (perform debounce first) 57 | ButtonID getPressedButtonID() 58 | { 59 | if(getButtonState(SEL_BUTTON_PIN)) 60 | return SEL_BUTTON; 61 | 62 | if(getButtonState(OK_BUTTON_PIN)) 63 | return OK_BUTTON; 64 | 65 | return NO_BUTTON; 66 | } 67 | 68 | 69 | // Buttons polling thread function 70 | __attribute__((noreturn)) 71 | void vButtonsThread(void *) 72 | { 73 | for (;;) 74 | { 75 | // Wait for a button 76 | ButtonID btn = getPressedButtonID(); 77 | if (btn != NO_BUTTON) 78 | { 79 | // Button pressed. Waiting for release 80 | TickType_t startTime = xTaskGetTickCount(); 81 | while(getPressedButtonID() != NO_BUTTON) 82 | vTaskDelay(ACTIVE_POLL_PERIOD); 83 | 84 | // Prepare message to send 85 | ButtonMessage msg; 86 | msg.button = btn; 87 | 88 | // calc duration 89 | TickType_t duration = xTaskGetTickCount() - startTime; 90 | if(duration > VERY_LONG_PRESS_DURATION) 91 | msg.event = BUTTON_VERY_LONG_PRESS; 92 | else 93 | if(duration > LONG_PRESS_DURATION) 94 | msg.event = BUTTON_LONG_PRESS; 95 | else 96 | msg.event = BUTTON_CLICK; 97 | 98 | // Send the message 99 | buttonsQueue.send(msg, 0); 100 | } 101 | 102 | // TODO: Use different polling periods depending on global system state (off/idle/active) 103 | vTaskDelay(ACTIVE_POLL_PERIOD); 104 | } 105 | } 106 | 107 | 108 | bool waitForButtonMessage(ButtonMessage * msg, TickType_t xTicksToWait) 109 | { 110 | return buttonsQueue.receive(msg, xTicksToWait); 111 | } 112 | -------------------------------------------------------------------------------- /Src/ButtonsThread.h: -------------------------------------------------------------------------------- 1 | #ifndef BUTTONS_H_ 2 | #define BUTTONS_H_ 3 | 4 | #include 5 | 6 | // Forward declaration 7 | typedef uint32_t TickType_t; 8 | 9 | /// ButtonIDs 10 | enum ButtonID 11 | { 12 | NO_BUTTON, 13 | SEL_BUTTON, 14 | OK_BUTTON 15 | }; 16 | 17 | /// Button event happened 18 | enum ButtonEvent 19 | { 20 | BUTTON_CLICK, 21 | BUTTON_LONG_PRESS, 22 | BUTTON_VERY_LONG_PRESS 23 | }; 24 | 25 | /// Message structure that is passed from buttons thread to UI task 26 | struct ButtonMessage 27 | { 28 | ButtonID button; 29 | ButtonEvent event; 30 | }; 31 | 32 | // Initialize buttons, ports, queue and related stuff 33 | void initButtons(); 34 | 35 | // Buttons are being monitored in a dedicated task. 36 | // When button click or long press is detected corresponding message is sent to UI task 37 | void vButtonsThread(void *pvParameters); 38 | 39 | // Wait until a button is pressed 40 | bool waitForButtonMessage(ButtonMessage * msg, TickType_t xTicksToWait); 41 | 42 | #endif /* BUTTONS_H_ */ 43 | -------------------------------------------------------------------------------- /Src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Build rules for GPS logger target. 2 | # App specific compiler/linker settings are also defined here 3 | 4 | SET(SOURCE_FILES 5 | # Screens and screen management stuff 6 | Screens/AltitudeScreen.cpp 7 | Screens/AltitudeScreen.h 8 | Screens/CurrentPositionScreen.cpp 9 | Screens/CurrentPositionScreen.h 10 | Screens/CurrentTimeScreen.cpp 11 | Screens/CurrentTimeScreen.h 12 | Screens/DebugScreen.cpp 13 | Screens/DebugScreen.h 14 | Screens/MemDumpScreen.cpp 15 | Screens/MemDumpScreen.h 16 | Screens/OdometerActionScreen.cpp 17 | Screens/OdometerActionScreen.h 18 | Screens/OdometerScreen.cpp 19 | Screens/OdometerScreen.h 20 | Screens/ParentScreen.cpp 21 | Screens/ParentScreen.h 22 | Screens/SatellitesScreen.cpp 23 | Screens/SatellitesScreen.h 24 | Screens/Screen.cpp 25 | Screens/Screen.h 26 | Screens/ScreenManager.cpp 27 | Screens/ScreenManager.h 28 | Screens/SelectorScreen.cpp 29 | Screens/SelectorScreen.h 30 | Screens/SettingsGroupScreen.cpp 31 | Screens/SettingsGroupScreen.h 32 | Screens/SpeedScreen.cpp 33 | Screens/SpeedScreen.h 34 | Screens/SPIDisplayDriver.cpp 35 | Screens/SPIDisplayDriver.h 36 | Screens/TimeZoneScreen.cpp 37 | Screens/TimeZoneScreen.h 38 | 39 | GPS/GPSDataModel.cpp 40 | GPS/GPSDataModel.h 41 | GPS/GPSOdometer.cpp 42 | GPS/GPSOdometer.h 43 | GPS/GPSSatellitesData.cpp 44 | GPS/GPSSatellitesData.h 45 | GPS/GPSThread.cpp 46 | GPS/GPSThread.h 47 | 48 | 8x12Font.cpp 49 | 8x12Font.h 50 | BoardInit.cpp 51 | BoardInit.h 52 | ButtonsThread.cpp 53 | ButtonsThread.h 54 | # FontTest.cpp 55 | # FontTest.h 56 | FreeRTOSHelpers.h 57 | GPSLogger.cpp 58 | IdleThread.cpp 59 | IdleThread.h 60 | LEDThread.cpp 61 | LEDThread.h 62 | PrintUtils.cpp 63 | PrintUtils.h 64 | # SdFatSPIDriver.cpp 65 | # SdFatSPIDriver.h 66 | # SdMscDriver.cpp 67 | # SdMscDriver.h 68 | SDThread.cpp 69 | SDThread.h 70 | SerialDebugLogger.cpp 71 | SerialDebugLogger.h 72 | Thread.h 73 | TimeFont.cpp 74 | TimeFont.h 75 | USBDebugLogger.cpp 76 | USBDebugLogger.h 77 | ) 78 | 79 | INCLUDE_DIRECTORIES( 80 | . 81 | ${GPSLOGGER_LIBS_DIR}/AdafruitGFX 82 | ${GPSLOGGER_LIBS_DIR}/Adafruit_SSD1306 83 | ${GPSLOGGER_LIBS_DIR}/NeoGPS 84 | # ${GPSLOGGER_LIBS_DIR}/SdFat 85 | ${GPSLOGGER_LIBS_DIR}/FreeRTOS 86 | ${GPSLOGGER_LIBS_DIR}/USB/Core 87 | ${GPSLOGGER_LIBS_DIR}/USB/CDC 88 | ${GPSLOGGER_LIBS_DIR}/USB/MSC 89 | ${GPSLOGGER_LIBS_DIR}/USB/MSC_CDC 90 | ) 91 | 92 | # Do not link to libc or newlib-nano - we are not using anything from that 93 | SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --specs=nosys.specs") 94 | 95 | ADD_EXECUTABLE(GPSLogger ${SOURCE_FILES}) 96 | TARGET_LINK_LIBRARIES(GPSLogger 97 | NeoGPS 98 | FreeRTOS 99 | # SDFAT 100 | AdafruitGFX 101 | AdafruitSSD1306 102 | USB 103 | MiniArduino 104 | HAL 105 | m 106 | ) 107 | 108 | TARGET_COMPILE_DEFINITIONS(GPSLogger PRIVATE 109 | -DENABLE_ARDUINO_FEATURES=0 #Disable SdFat stuff 110 | ) 111 | 112 | STM32_GENERATE_MAP_FILE(GPSLogger) 113 | STM32_SET_TARGET_PROPERTIES(GPSLogger) 114 | STM32_PRINT_SIZE_OF_TARGETS(GPSLogger) 115 | 116 | # Additional handy targets 117 | STM32_ADD_HEX_BIN_TARGETS(GPSLogger) 118 | STM32_ADD_DUMP_TARGET(GPSLogger) 119 | -------------------------------------------------------------------------------- /Src/FontTest.h: -------------------------------------------------------------------------------- 1 | /* 2 | * FontTest.h 3 | * 4 | * Created: 28.01.2017 22:37:32 5 | * Author: GrafAlex 6 | */ 7 | 8 | 9 | #ifndef FONTTEST_H_ 10 | #define FONTTEST_H_ 11 | 12 | void RunFontTest(); 13 | void SwitchToNextFont(); 14 | 15 | #endif /* FONTTEST_H_ */ -------------------------------------------------------------------------------- /Src/FreeRTOSHelpers.h: -------------------------------------------------------------------------------- 1 | #ifndef FREERTOSHELPERS_H_ 2 | #define FREERTOSHELPERS_H_ 3 | 4 | #include "Arduino_FreeRTOS.h" 5 | 6 | class MutexLocker 7 | { 8 | public: 9 | MutexLocker(SemaphoreHandle_t mtx) 10 | { 11 | mutex = mtx; 12 | xSemaphoreTake(mutex, portMAX_DELAY); 13 | } 14 | 15 | ~MutexLocker() 16 | { 17 | xSemaphoreGive(mutex); 18 | } 19 | 20 | private: 21 | SemaphoreHandle_t mutex; 22 | }; 23 | 24 | template 25 | class Queue 26 | { 27 | QueueHandle_t queueHandle; 28 | StaticQueue_t queueControlBlock; 29 | T queueStorage[size]; 30 | 31 | public: 32 | Queue() 33 | { 34 | queueHandle = xQueueCreateStatic(size, 35 | sizeof(T), 36 | reinterpret_cast(queueStorage), 37 | &queueControlBlock); 38 | } 39 | 40 | //operator QueueHandle_t() const 41 | //{ 42 | // return queueHandle; 43 | //} 44 | 45 | bool receive(T * val, TickType_t xTicksToWait) 46 | { 47 | return xQueueReceive(queueHandle, val, xTicksToWait); 48 | } 49 | 50 | bool send(T & val, TickType_t xTicksToWait) 51 | { 52 | return xQueueSend(queueHandle, &val, xTicksToWait); 53 | } 54 | }; 55 | 56 | class Sema 57 | { 58 | SemaphoreHandle_t sema; 59 | StaticSemaphore_t semaControlBlock; 60 | 61 | public: 62 | Sema() 63 | { 64 | sema = xSemaphoreCreateBinaryStatic(&semaControlBlock); 65 | } 66 | 67 | //operator TaskHandle_t() const 68 | //{ 69 | // return xSema; 70 | //} 71 | 72 | BaseType_t giveFromISR() 73 | { 74 | BaseType_t xHigherPriorityTaskWoken; 75 | xSemaphoreGiveFromISR(sema, &xHigherPriorityTaskWoken); 76 | return xHigherPriorityTaskWoken; 77 | } 78 | 79 | BaseType_t give() 80 | { 81 | return xSemaphoreGive(sema); 82 | } 83 | 84 | BaseType_t take(TickType_t xTicksToWait) 85 | { 86 | return xSemaphoreTake(sema, xTicksToWait); 87 | } 88 | }; 89 | 90 | #endif //FREERTOSHELPERS_H_ 91 | -------------------------------------------------------------------------------- /Src/GPS/GPSDataModel.h: -------------------------------------------------------------------------------- 1 | #ifndef GPSDATA_H_ 2 | #define GPSDATA_H_ 3 | 4 | #include "GPSSatellitesData.h" 5 | #include "Arduino_FreeRTOS.h" 6 | 7 | // Forward declarations 8 | class gps_fix; 9 | class GPSSatellitesData; 10 | class NMEAGPS; 11 | class GPSOdometer; 12 | class GPSOdometerData; 13 | 14 | const uint8_t ODOMERTERS_COUNT = 3; 15 | 16 | /** 17 | * GPS data model. Encapsulates all the knowledge about various GPS related data in the device 18 | */ 19 | class GPSDataModel 20 | { 21 | public: 22 | /// A single instance of the model 23 | static GPSDataModel & instance(); 24 | 25 | void processNewGPSFix(const gps_fix & fix); 26 | void processNewSatellitesData(NMEAGPS::satellite_view_t * sattelites, uint8_t count); 27 | gps_fix getGPSFix() const; 28 | GPSSatellitesData getSattelitesData() const; 29 | 30 | float getVerticalSpeed() const; 31 | int timeDifference() const; 32 | 33 | // Odometers 34 | GPSOdometerData getOdometerData(uint8_t idx) const; 35 | void resumeOdometer(uint8_t idx); 36 | void pauseOdometer(uint8_t idx); 37 | void resetOdometer(uint8_t idx); 38 | void resumeAllOdometers(); 39 | void pauseAllOdometers(); 40 | void resetAllOdometers(); 41 | 42 | private: 43 | gps_fix cur_fix; /// most recent fix data 44 | gps_fix prev_fix; /// previously set fix data 45 | GPSSatellitesData sattelitesData; // Sattelites count and signal power 46 | GPSOdometer * odometers[ODOMERTERS_COUNT]; 47 | bool odometerWasActive[ODOMERTERS_COUNT]; 48 | 49 | SemaphoreHandle_t xGPSDataMutex; 50 | StaticSemaphore_t xGPSDataMutexBuffer; 51 | 52 | GPSDataModel(); 53 | GPSDataModel( const GPSDataModel &c ); 54 | GPSDataModel& operator=( const GPSDataModel &c ); 55 | }; //GPSDataModel 56 | 57 | #endif //GPSDATA_H_ 58 | -------------------------------------------------------------------------------- /Src/GPS/GPSOdometer.cpp: -------------------------------------------------------------------------------- 1 | #include "NMEAGPS.h" 2 | 3 | #include "GPSOdometer.h" 4 | 5 | bool isValid(const NeoGPS::Location_t & loc) 6 | { 7 | return loc.lat() && loc.lon(); 8 | } 9 | 10 | GPSOdometerData::GPSOdometerData() 11 | { 12 | reset(); 13 | } 14 | 15 | void GPSOdometerData::reset() 16 | { 17 | active = false; 18 | 19 | startLocation.init(); 20 | lastLocation.init(); 21 | odometer = 0.; 22 | startAltitude = 0; 23 | curAltitude = 0; 24 | startTime = 0; 25 | sessionStartTime = 0; 26 | totalTime = 0; 27 | activeTime = 0; 28 | activeTimeAccumulator = 0; 29 | maxSpeed = 0.; 30 | } 31 | 32 | float GPSOdometerData::getAvgSpeed() const 33 | { 34 | // Prevent division by zero 35 | if(activeTimeAccumulator == 0) 36 | return 0.; 37 | 38 | return odometer / getActiveTime(); 39 | } 40 | 41 | float GPSOdometerData::getDirectDistance() const 42 | { 43 | return NeoGPS::Location_t::DistanceKm(lastLocation, startLocation); 44 | } 45 | 46 | GPSOdometer::GPSOdometer() 47 | { 48 | data.reset(); 49 | } 50 | 51 | void GPSOdometer::processNewFix(const gps_fix & fix) 52 | { 53 | if(data.active) 54 | { 55 | // Fill starting position if needed 56 | if(fix.valid.location && !isValid(data.startLocation)) 57 | data.startLocation = fix.location; 58 | 59 | // Fill starting altitude if neede 60 | if(fix.valid.altitude && !data.startAltitude) // I know altitude can be zero, but real zero cm altutude would be very rare condition. Hope this is not a big deal 61 | data.startAltitude = fix.altitude_cm(); 62 | 63 | // Fill starting times if needed 64 | if(fix.valid.time) 65 | { 66 | if(!data.startTime) 67 | data.startTime = fix.dateTime; 68 | if(!data.sessionStartTime) 69 | data.sessionStartTime = fix.dateTime; 70 | } 71 | 72 | // Increment the odometer 73 | if(fix.valid.location) 74 | { 75 | // but only if previous location is really valid 76 | if(isValid(data.lastLocation)) 77 | data.odometer += NeoGPS::Location_t::DistanceKm(fix.location, data.lastLocation); 78 | 79 | // In any case store current (valid) fix 80 | data.lastLocation = fix.location; 81 | } 82 | 83 | // Store current altitude 84 | if(fix.valid.altitude) 85 | data.curAltitude = fix.altitude_cm(); 86 | 87 | // update active time values 88 | if(fix.valid.time) 89 | data.activeTime = fix.dateTime - data.sessionStartTime; 90 | 91 | // update max speed value 92 | if(fix.valid.speed && fix.speed_kph() > data.maxSpeed) 93 | data.maxSpeed = fix.speed_kph(); 94 | } 95 | 96 | //Total time can be updated regardless of active state 97 | if(fix.valid.time && data.startTime) 98 | data.totalTime = fix.dateTime - data.startTime; 99 | } 100 | 101 | void GPSOdometer::startOdometer() 102 | { 103 | data.active = true; 104 | 105 | // Reset session values 106 | data.sessionStartTime = 0; 107 | data.activeTime = 0; 108 | } 109 | 110 | void GPSOdometer::pauseOdometer() 111 | { 112 | data.active = false; 113 | 114 | data.activeTimeAccumulator += data.activeTime; 115 | data.activeTime = 0; 116 | } 117 | 118 | void GPSOdometer::resetOdometer() 119 | { 120 | data.reset(); 121 | } 122 | -------------------------------------------------------------------------------- /Src/GPS/GPSOdometer.h: -------------------------------------------------------------------------------- 1 | #ifndef __GPSODOMETER_H__ 2 | #define __GPSODOMETER_H__ 3 | 4 | #include 5 | 6 | // This class represents a single odometer data with no logic around 7 | class GPSOdometerData 8 | { 9 | // GPSOdometer and its data are basically a single object. The difference is only that data can be easily copied 10 | // while GPS odometer object is not supposed to. Additionally access to Odometer object is protected with a mutex 11 | // in the model object 12 | // In order not to overcomplicte design I am allowing GPS Odometer to operate its data members directly. 13 | friend class GPSOdometer; 14 | 15 | bool active; 16 | 17 | NeoGPS::Location_t startLocation; 18 | NeoGPS::Location_t lastLocation; 19 | 20 | float odometer; 21 | int16_t startAltitude; 22 | int16_t curAltitude; 23 | 24 | clock_t startTime; ///! When odometer was turned on for the first time 25 | clock_t sessionStartTime; ///! When odometer was resumed for the current session 26 | clock_t totalTime; ///! Total time for the odometer (difference between now and startTime) 27 | clock_t activeTime; ///! Duration of the current session (difference between now and sessionStartTime) 28 | clock_t activeTimeAccumulator; ///! Sum of all active session duration (not including current one) 29 | 30 | float maxSpeed; 31 | 32 | public: 33 | GPSOdometerData(); 34 | void reset(); 35 | 36 | // getters 37 | bool isActive() const {return active;} 38 | float getOdometerValue() const {return odometer;} 39 | int16_t getAltitudeDifference() const {return (curAltitude - startAltitude) / 100.;} // altitude is in cm 40 | clock_t getTotalTime() const {return totalTime;} 41 | clock_t getActiveTime() const {return activeTimeAccumulator + activeTime;} 42 | float getMaxSpeed() const {return maxSpeed;} 43 | float getAvgSpeed() const; 44 | float getDirectDistance() const; 45 | }; 46 | 47 | // This is an active odometer object that operates on its odometer data 48 | class GPSOdometer 49 | { 50 | GPSOdometerData data; 51 | 52 | public: 53 | GPSOdometer(); 54 | 55 | // odometer control 56 | void processNewFix(const gps_fix & fix); 57 | void startOdometer(); 58 | void pauseOdometer(); 59 | void resetOdometer(); 60 | 61 | // Some data getters 62 | GPSOdometerData getData() {return data;} 63 | bool isActive() const {return data.isActive();} 64 | }; //GPSOdometer 65 | 66 | #endif //__GPSODOMETER_H__ 67 | -------------------------------------------------------------------------------- /Src/GPS/GPSSatellitesData.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "GPSSatellitesData.h" 4 | 5 | GPSSatellitesData::GPSSatellitesData() 6 | { 7 | } 8 | 9 | void GPSSatellitesData::parseSatellitesData(NMEAGPS::satellite_view_t * sattelites, uint8_t count) 10 | { 11 | sat_count = count; 12 | for(uint8_t i = 0; i < count; i++) 13 | { 14 | satellitesData[i].snr = sattelites[i].snr; 15 | satellitesData[i].tracked = sattelites[i].tracked; 16 | } 17 | } -------------------------------------------------------------------------------- /Src/GPS/GPSSatellitesData.h: -------------------------------------------------------------------------------- 1 | #ifndef GPSSATELLITESDATA_H_ 2 | #define GPSSATELLITESDATA_H_ 3 | 4 | #include 5 | 6 | const uint8_t SAT_ARRAY_SIZE = 20; // Must match NMEAGPS_MAX_SATELLITES 7 | 8 | // Forward declaration 9 | class NMEAGPS; 10 | //struct NMEAGPS::satellite_view_t; 11 | 12 | class GPSSatellitesData 13 | { 14 | // Partial copy of NMEAGPS::satellite_view_t trimmed to used data 15 | struct SatteliteData 16 | { 17 | uint8_t snr; 18 | bool tracked; 19 | }; 20 | 21 | SatteliteData satellitesData[SAT_ARRAY_SIZE]; 22 | uint8_t sat_count; 23 | 24 | public: 25 | GPSSatellitesData(); 26 | 27 | void parseSatellitesData(NMEAGPS::satellite_view_t * sattelites, uint8_t count); 28 | 29 | uint8_t getSattelitesCount() const {return sat_count;} 30 | uint8_t getSatteliteSNR(uint8_t sat) const {return satellitesData[sat].snr;} 31 | bool isSatteliteTracked(uint8_t sat) const {return satellitesData[sat].tracked;} 32 | }; 33 | 34 | #endif //GPSSATELLITESDATA_H_ 35 | -------------------------------------------------------------------------------- /Src/GPS/GPSThread.h: -------------------------------------------------------------------------------- 1 | #ifndef GPSTHREAD_H_ 2 | #define GPSTHREAD_H_ 3 | 4 | void initGPS(); 5 | void vGPSTask(void *pvParameters); 6 | 7 | #endif //GPSTHREAD_H_ 8 | -------------------------------------------------------------------------------- /Src/GPSLogger.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "Screens/ScreenManager.h" 4 | #include "GPS/GPSThread.h" 5 | 6 | #include "BoardInit.h" 7 | #include "LEDThread.h" 8 | #include "ButtonsThread.h" 9 | //#include "SDThread.h" 10 | #include "USBDebugLogger.h" 11 | //#include "SerialDebugLogger.h" 12 | //#include "SdMscDriver.h" 13 | #include "Thread.h" 14 | 15 | static Thread ledThread(vLEDThread, "LED Thread", nullptr, tskIDLE_PRIORITY + 1); 16 | static Thread<768> displayThread(vDisplayTask, "Display Task", nullptr, tskIDLE_PRIORITY + 2); 17 | static Thread buttonsThread(vButtonsThread, "Buttons Thread", nullptr, tskIDLE_PRIORITY + 2); 18 | static Thread<256> gpsThread(vGPSTask, "GPS Task", nullptr, tskIDLE_PRIORITY + 3); 19 | 20 | //xTaskCreate(vSDThread, "SD Thread", 512, NULL, tskIDLE_PRIORITY + 1, NULL); 21 | //xTaskCreate(xSDIOThread, "SD IO executor", 256, NULL, tskIDLE_PRIORITY + 3, NULL); 22 | //xTaskCreate(xSDTestThread, "SD test thread", 200, NULL, tskIDLE_PRIORITY + 3, NULL); 23 | 24 | 25 | int main(void) 26 | { 27 | InitBoard(); 28 | //initDebugSerial(); 29 | 30 | portENABLE_INTERRUPTS(); // To allow halt() use HAL_Delay() 31 | 32 | // Initialize SD card before initializing USB 33 | // if(!initSDIOThread()) 34 | // halt(7); 35 | 36 | initUSB(); 37 | 38 | initButtons(); 39 | //initSDThread(); 40 | 41 | // Run scheduler and all the threads 42 | vTaskStartScheduler(); 43 | 44 | // Never going to be here 45 | return 0; 46 | } 47 | -------------------------------------------------------------------------------- /Src/IdleThread.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "IdleThread.h" 4 | 5 | static const uint8_t periodLen = 9; // 2^periodLen ticks 6 | 7 | static volatile TickType_t curIdleTicks = 0; 8 | static volatile TickType_t lastCountedTick = 0; 9 | static volatile TickType_t lastCountedPeriod = 0; 10 | static volatile TickType_t lastPeriodIdleValue = 0; 11 | static volatile TickType_t minIdleValue = 1 << periodLen; 12 | 13 | static StaticTask_t xIdleTaskBuffer; 14 | static StackType_t xIdleStack[ configMINIMAL_STACK_SIZE ]; 15 | 16 | extern "C" 17 | void vApplicationGetIdleTaskMemory( StaticTask_t **ppxIdleTaskTCBBuffer, StackType_t **ppxIdleTaskStackBuffer, uint32_t *pulIdleTaskStackSize) 18 | { 19 | *ppxIdleTaskTCBBuffer = &xIdleTaskBuffer; 20 | *ppxIdleTaskStackBuffer = xIdleStack; 21 | *pulIdleTaskStackSize = configMINIMAL_STACK_SIZE; 22 | } 23 | 24 | extern "C" void vApplicationIdleHook( void ) 25 | { 26 | // Process idle tick counter 27 | volatile TickType_t curTick = xTaskGetTickCount(); 28 | if(curTick != lastCountedTick) 29 | { 30 | curIdleTicks++; 31 | lastCountedTick = curTick; 32 | } 33 | 34 | // Store idle metrics each ~0.5 seconds (512 ticks) 35 | curTick >>= periodLen; 36 | if(curTick > lastCountedPeriod) 37 | { 38 | lastPeriodIdleValue = curIdleTicks; 39 | curIdleTicks = 0; 40 | lastCountedPeriod = curTick; 41 | 42 | // Store the max value 43 | if(lastPeriodIdleValue < minIdleValue) 44 | minIdleValue = lastPeriodIdleValue; 45 | } 46 | } 47 | 48 | float getCPULoad() 49 | { 50 | return 100. - 100. * lastPeriodIdleValue / (1 << periodLen); 51 | } 52 | 53 | float getMaxCPULoad() 54 | { 55 | return 100. - 100. * minIdleValue / (1 << periodLen); 56 | } 57 | 58 | extern "C" void yield() 59 | { 60 | //taskYIELD(); 61 | } 62 | -------------------------------------------------------------------------------- /Src/IdleThread.h: -------------------------------------------------------------------------------- 1 | #ifndef IDLETHREAD_H_ 2 | #define IDLETHREAD_H_ 3 | 4 | float getCPULoad(); 5 | float getMaxCPULoad(); 6 | 7 | #endif //IDLETHREAD_H_ 8 | -------------------------------------------------------------------------------- /Src/LEDThread.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "LEDThread.h" 6 | #include 7 | #include "USBDebugLogger.h" 8 | #include "SerialDebugLogger.h" 9 | 10 | static volatile uint8_t ledStatus = 0xff; 11 | 12 | // Class to encapsulate working with onboard LED(s) 13 | // 14 | // Note: this class initializes corresponding pins in the constructor. 15 | // May not be working properly if objects of this class are created as global variables 16 | class LEDDriver 17 | { 18 | const uint32_t ledG = LL_GPIO_PIN_14; 19 | const uint32_t ledR = LL_GPIO_PIN_15; 20 | bool inited = false; 21 | public: 22 | LEDDriver() 23 | { 24 | 25 | } 26 | 27 | void init() 28 | { 29 | if(inited) 30 | return; 31 | 32 | //enable clock to the GPIOB peripheral 33 | __HAL_RCC_GPIOB_CLK_ENABLE(); 34 | 35 | // Init LED pins as output 36 | LL_GPIO_SetPinMode(GPIOB, ledG, LL_GPIO_MODE_OUTPUT); 37 | LL_GPIO_SetPinOutputType(GPIOB, ledG, LL_GPIO_OUTPUT_PUSHPULL); 38 | LL_GPIO_SetPinSpeed(GPIOB, ledG, LL_GPIO_SPEED_FREQ_LOW); 39 | LL_GPIO_SetOutputPin(GPIOB, ledG); 40 | LL_GPIO_SetPinMode(GPIOB, ledR, LL_GPIO_MODE_OUTPUT); 41 | LL_GPIO_SetPinOutputType(GPIOB, ledR, LL_GPIO_OUTPUT_PUSHPULL); 42 | LL_GPIO_SetPinSpeed(GPIOB, ledR, LL_GPIO_SPEED_FREQ_LOW); 43 | LL_GPIO_SetOutputPin(GPIOB, ledR); 44 | 45 | inited = true; 46 | } 47 | 48 | void turnOnG() 49 | { 50 | LL_GPIO_ResetOutputPin(GPIOB, ledG); 51 | } 52 | 53 | void turnOffG() 54 | { 55 | LL_GPIO_SetOutputPin(GPIOB, ledG); 56 | } 57 | 58 | void toggleG() 59 | { 60 | LL_GPIO_TogglePin(GPIOB, ledG); 61 | } 62 | 63 | void turnOnR() 64 | { 65 | LL_GPIO_ResetOutputPin(GPIOB, ledR); 66 | } 67 | 68 | void turnOffR() 69 | { 70 | LL_GPIO_SetOutputPin(GPIOB, ledR); 71 | } 72 | 73 | void toggleR() 74 | { 75 | LL_GPIO_TogglePin(GPIOB, ledR); 76 | } 77 | }; 78 | 79 | static LEDDriver led; 80 | 81 | void blink(uint8_t status) 82 | { 83 | led.init(); 84 | 85 | for(int i=0; i<3; i++) 86 | { 87 | led.turnOnR(); 88 | if(status & 0x4) 89 | HAL_Delay(300); 90 | else 91 | HAL_Delay(100); 92 | led.turnOffR(); 93 | 94 | status <<= 1; 95 | 96 | HAL_Delay(200); 97 | } 98 | } 99 | 100 | void setLedStatus(uint8_t status) 101 | { 102 | ledStatus = status; 103 | } 104 | 105 | __attribute__((noreturn)) 106 | void halt(uint8_t status) 107 | { 108 | led.init(); 109 | 110 | while(true) 111 | { 112 | blink(status); 113 | 114 | HAL_Delay(700); 115 | } 116 | } 117 | 118 | __attribute__((noreturn)) 119 | void vLEDThread(void *) 120 | { 121 | led.init(); 122 | 123 | // Just blink once in 2 seconds 124 | for (;;) 125 | { 126 | vTaskDelay(2000); 127 | 128 | if(ledStatus == 0xff) 129 | { 130 | led.turnOnG(); 131 | vTaskDelay(100); 132 | led.turnOffG(); 133 | } 134 | else 135 | { 136 | blink(ledStatus); 137 | } 138 | 139 | usbDebugWrite("Test\n"); 140 | //serialDebugWrite("SerialTest\n"); 141 | } 142 | } 143 | -------------------------------------------------------------------------------- /Src/LEDThread.h: -------------------------------------------------------------------------------- 1 | #ifndef LEDDRIVER_H 2 | #define LEDDRIVER_H 3 | 4 | #include 5 | 6 | // A thread that is responsible for showing current device status via onboard LED(s) 7 | void vLEDThread(void *pvParameters); 8 | 9 | void blink(uint8_t status); 10 | void setLedStatus(uint8_t status); 11 | void halt(uint8_t status); 12 | 13 | #endif // LEDDRIVER_H 14 | -------------------------------------------------------------------------------- /Src/PrintUtils.h: -------------------------------------------------------------------------------- 1 | #ifndef UTILS_H_ 2 | #define UTILS_H_ 3 | 4 | #include // for uint16_t 5 | #include 6 | #include 7 | 8 | // Forward declarations 9 | typedef uint32_t clock_t; 10 | namespace NeoGPS 11 | { 12 | struct time_t; 13 | } 14 | 15 | // Base class for char consumer functor 16 | struct PrintTarget 17 | { 18 | virtual void operator()(char c) = 0; 19 | virtual void operator()(const char *buffer, size_t size, bool reverse = false) 20 | { 21 | // Copy data to the buffer 22 | for(size_t i=0; i < size; i++) 23 | { 24 | if(reverse) 25 | --buffer; 26 | 27 | operator()(*buffer); 28 | 29 | if(!reverse) 30 | buffer++; 31 | } 32 | } 33 | }; 34 | 35 | // Print formatted string to a passed char consumer 36 | void print(PrintTarget & target, const char * fmt, va_list args); 37 | void print(PrintTarget & target, const char * fmt, ...); 38 | 39 | // Print a formatted string to a buffer 40 | void bufprint(char * buf, size_t n, const char * fmt, ...); 41 | 42 | // Print a formatted string to display at current position 43 | void printToDisplay(const char * fmt, ...); 44 | 45 | 46 | 47 | /// Helper function to print a single integer with specified width to a passed buffer 48 | void printNumber(char * buf, uint16_t value, uint8_t digits, bool leadingZeros = true); 49 | 50 | 51 | /// Helper class to print float numbers according to specified options 52 | class FloatPrinter : public Printable 53 | { 54 | char buf[8]; // Print numbers no longer than 7 digits including sign and point symbols 55 | uint8_t pos; // position in the buffer with the first meaningful char 56 | 57 | public: 58 | FloatPrinter(float value, uint8_t width, bool leadingZeros = false, bool alwaysPrintSign = false); 59 | 60 | virtual size_t printTo(Print& p) const; 61 | }; 62 | 63 | 64 | 65 | #endif //UTILS_H_ 66 | -------------------------------------------------------------------------------- /Src/SDThread.h: -------------------------------------------------------------------------------- 1 | #ifndef SDTHREAD_H 2 | #define SDTHREAD_H 3 | 4 | #include 5 | 6 | // Maximum lenth of a single raw GPS data message (not including terminating \n) 7 | const uint8_t maxRawGPSDataLen = 80; 8 | // Returns a pointer to an internal buffer where GPS thread can accumulate raw GPS data (not more than maxRawGPSDataLen symbols) 9 | char * requestRawGPSBuffer(); 10 | // Confirm that internal GPS buffer contains len chars and store them to raw GPS dump file 11 | void ackRawGPSData(uint8_t len); 12 | 13 | // A thread that owns communication with SD card 14 | void initSDThread(); 15 | void vSDThread(void *pvParameters); 16 | 17 | #endif // SDTHREAD_H 18 | -------------------------------------------------------------------------------- /Src/Screens/AltitudeScreen.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "AltitudeScreen.h" 5 | #include "ScreenManager.h" 6 | #include "TimeFont.h" 7 | #include "8x12Font.h" 8 | #include "GPS/GPSDataModel.h" 9 | #include "PrintUtils.h" 10 | 11 | extern Adafruit_SSD1306 display; 12 | 13 | AltitudeScreen::AltitudeScreen() 14 | { 15 | } 16 | 17 | void AltitudeScreen::drawScreen() const 18 | { 19 | // Get the gps fix data 20 | gps_fix gpsFix = GPSDataModel::instance().getGPSFix(); 21 | 22 | // Draw Altitude 23 | // TODO draw '----' if no GPS signal found. Requires new character in font 24 | char buf[7]; // 6 symbols + trailing zero 25 | strcpy(buf, "-----"); 26 | if(gpsFix.valid.altitude) 27 | { 28 | if(gpsFix.alt.whole >= 0) 29 | printNumber(buf, gpsFix.alt.whole, 5); //TODO add leading spaces 30 | else 31 | printNumber(buf+1, abs(gpsFix.alt.whole), 4); // there could be negative altitude 32 | } 33 | display.setFont(&TimeFont); 34 | display.setCursor(0,31); 35 | display.print(buf); 36 | 37 | // Draw Altitude units 38 | display.setFont(&Monospace8x12Font); // TODO: Use slightly larger bold font 39 | display.setCursor(82, 20); 40 | display.print("m"); 41 | 42 | // Draw vertical speed 43 | float vspeed = GPSDataModel::instance().getVerticalSpeed(); 44 | if(!isnan(vspeed)) 45 | { 46 | display.setFont(NULL); 47 | display.setCursor(80, 24); 48 | display.print(FloatPrinter(vspeed, 5)); 49 | display.print("m/s"); //TODO: Add a space before 'm/s'. Requires text wrapping fix in GFX library 50 | } 51 | } 52 | 53 | void AltitudeScreen::onOkButton() 54 | { 55 | backToParentScreen(); 56 | } 57 | 58 | const char * AltitudeScreen::getSelButtonText() const 59 | { 60 | static const char text[] = ""; 61 | return text; 62 | } 63 | 64 | const char * AltitudeScreen::getOkButtonText() const 65 | { 66 | static const char text[] = "BACK"; 67 | return text; 68 | } 69 | -------------------------------------------------------------------------------- /Src/Screens/AltitudeScreen.h: -------------------------------------------------------------------------------- 1 | #ifndef __ALTITUDESCREEN_H__ 2 | #define __ALTITUDESCREEN_H__ 3 | 4 | #include "Screen.h" 5 | 6 | class AltitudeScreen: public Screen 7 | { 8 | public: 9 | AltitudeScreen(); 10 | 11 | virtual void drawScreen() const; 12 | 13 | virtual void onOkButton(); 14 | 15 | virtual const char * getSelButtonText() const; 16 | virtual const char * getOkButtonText() const; 17 | 18 | private: 19 | AltitudeScreen( const AltitudeScreen &c ); 20 | AltitudeScreen& operator=( const AltitudeScreen &c ); 21 | 22 | }; //AltitudeScreen 23 | 24 | #endif //__ALTITUDESCREEN_H__ 25 | -------------------------------------------------------------------------------- /Src/Screens/CurrentPositionScreen.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #undef degrees //defined in wirish.h 3 | #include 4 | 5 | #include "8x12Font.h" 6 | #include "PrintUtils.h" 7 | #include "ScreenManager.h" 8 | #include "CurrentPositionScreen.h" 9 | #include "GPS/GPSDataModel.h" 10 | 11 | extern Adafruit_SSD1306 display; 12 | 13 | void CurrentPositionScreen::drawScreen() const 14 | { 15 | // Get the current Fix data 16 | gps_fix gpsFix = GPSDataModel::instance().getGPSFix(); 17 | 18 | static char latitudeString[17]; // 16 symbols + terminating zerro 19 | static char longtitudeString[17]; 20 | 21 | // string template 22 | strcpy(latitudeString, "LA: --\"--'--.-- "); 23 | strcpy(longtitudeString, "LO:---\"--'--.-- "); 24 | 25 | display.setFont(&Monospace8x12Font); 26 | display.setCursor(0,20); 27 | if(gpsFix.valid.location) 28 | { 29 | // Latitude 30 | printNumber(latitudeString + 4, gpsFix.latitudeDMS.degrees, 2); 31 | printNumber(latitudeString + 7, gpsFix.latitudeDMS.minutes, 2); 32 | printNumber(latitudeString + 10, gpsFix.latitudeDMS.seconds_whole, 2); 33 | printNumber(latitudeString + 13, gpsFix.latitudeDMS.seconds_frac, 2); 34 | latitudeString[15] = gpsFix.latitudeDMS.NS(); 35 | 36 | // Longtitude 37 | printNumber(longtitudeString + 3, gpsFix.longitudeDMS.degrees, 3); 38 | printNumber(longtitudeString + 7, gpsFix.longitudeDMS.minutes, 2); 39 | printNumber(longtitudeString + 10, gpsFix.longitudeDMS.seconds_whole, 2); 40 | printNumber(longtitudeString + 13, gpsFix.longitudeDMS.seconds_frac, 2); 41 | longtitudeString[15] = gpsFix.longitudeDMS.EW(); 42 | } 43 | 44 | display.setCursor(0,20); 45 | display.print(latitudeString); // TODO GFX library wraps the last symbol to new line 46 | display.setCursor(0,32); 47 | display.print(longtitudeString); 48 | } 49 | 50 | const char * CurrentPositionScreen::getOkButtonText() const 51 | { 52 | static const char text[] = "POI"; 53 | return text; 54 | } 55 | 56 | void CurrentPositionScreen::onOkButton() 57 | { 58 | static const char text[] = "Waypoint Saved!"; 59 | showMessageBox(text); 60 | } 61 | -------------------------------------------------------------------------------- /Src/Screens/CurrentPositionScreen.h: -------------------------------------------------------------------------------- 1 | #ifndef _POSITION_SCREEN_H_ 2 | #define _POSITION_SCREEN_H_ 3 | 4 | #include "Screen.h" 5 | 6 | class CurrentPositionScreen: public Screen 7 | { 8 | public: 9 | virtual void drawScreen() const; 10 | 11 | virtual void onOkButton(); 12 | 13 | protected: 14 | const char * getOkButtonText() const; 15 | }; 16 | 17 | #endif //_POSITION_SCREEN_H_ 18 | -------------------------------------------------------------------------------- /Src/Screens/CurrentTimeScreen.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "CurrentTimeScreen.h" 5 | #include "TimeZoneScreen.h" 6 | #include "TimeFont.h" 7 | #include "GPS/GPSDataModel.h" 8 | #include "PrintUtils.h" 9 | 10 | extern Adafruit_SSD1306 display; 11 | 12 | TimeZoneScreen timeZoneScreen; //TODO Move it to CurrentTimeScreen class 13 | 14 | void CurrentTimeScreen::drawScreen() const 15 | { 16 | // Get the date/time adjusted by selected timezone value 17 | gps_fix gpsFix = GPSDataModel::instance().getGPSFix(); 18 | NeoGPS::time_t dateTime = gpsFix.dateTime + timeZoneScreen.getCurrentTimeZone() * 60; //timeZone is in minutes 19 | 20 | // TODO: display approximate time even if GPS is not available 21 | 22 | display.setFont(&TimeFont); 23 | display.setCursor(0,31); 24 | 25 | // Draw a '~' symbol if no time is available from GPS. 26 | display.print(gpsFix.valid.time ? '<' : ';'); // '<' is remapeed to space, ';' is remapped to '~' 27 | printToDisplay("%02d:%02d:%02d", dateTime.hours, dateTime.minutes, dateTime.seconds); 28 | } 29 | 30 | CurrentTimeScreen::CurrentTimeScreen() 31 | { 32 | addChildScreen(&timeZoneScreen); 33 | } 34 | 35 | -------------------------------------------------------------------------------- /Src/Screens/CurrentTimeScreen.h: -------------------------------------------------------------------------------- 1 | #ifndef _TIME_SCREEN_H_ 2 | #define _TIME_SCREEN_H_ 3 | 4 | #include "ParentScreen.h" 5 | 6 | class CurrentTimeScreen: public ParentScreen 7 | { 8 | public: 9 | virtual void drawScreen() const; 10 | 11 | CurrentTimeScreen(); 12 | }; 13 | 14 | #endif //_TIME_SCREEN_H_ 15 | -------------------------------------------------------------------------------- /Src/Screens/DebugScreen.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "DebugScreen.h" 5 | #include "PrintUtils.h" 6 | #include "8x12Font.h" 7 | #include "ScreenManager.h" 8 | #include "IdleThread.h" 9 | 10 | extern Adafruit_SSD1306 display; 11 | 12 | enum PageId 13 | { 14 | IDLE_METRICS, 15 | STACK_METRICS, 16 | 17 | PAGES_COUNT 18 | }; 19 | 20 | // default constructor 21 | DebugScreen::DebugScreen() 22 | { 23 | currentPage = 0; 24 | } 25 | 26 | void DebugScreen::drawScreen() const 27 | { 28 | display.setFont(&Monospace8x12Font); 29 | 30 | switch(currentPage) 31 | { 32 | case IDLE_METRICS: 33 | { 34 | display.setCursor(0, 19); 35 | display.print("CPU Load: "); 36 | display.print(getCPULoad(), 1); 37 | 38 | display.setCursor(0, 32); 39 | display.print("Max Load: "); 40 | display.print(getMaxCPULoad(), 1); 41 | break; 42 | } 43 | case STACK_METRICS: 44 | display.setCursor(0, 19); 45 | display.print("Max Stack:"); 46 | 47 | display.setCursor(0, 32); 48 | //printToDisplay("%d", uxTaskGetStackHighWaterMark(NULL)); 49 | break; 50 | 51 | default: 52 | break; 53 | } 54 | } 55 | 56 | void DebugScreen::onSelButton() 57 | { 58 | currentPage++; 59 | currentPage %= PAGES_COUNT; 60 | } 61 | 62 | void DebugScreen::onOkButton() 63 | { 64 | backToParentScreen(); 65 | } 66 | 67 | const char * DebugScreen::getSelButtonText() const 68 | { 69 | static const char text[] = "NEXT"; 70 | return text; 71 | } 72 | 73 | const char * DebugScreen::getOkButtonText() const 74 | { 75 | static const char text[] = "OK"; 76 | return text; 77 | } 78 | -------------------------------------------------------------------------------- /Src/Screens/DebugScreen.h: -------------------------------------------------------------------------------- 1 | #ifndef __DEBUGSCREEN_H__ 2 | #define __DEBUGSCREEN_H__ 3 | 4 | #include "Screen.h" 5 | 6 | class DebugScreen : public Screen 7 | { 8 | public: 9 | DebugScreen(); 10 | 11 | virtual void drawScreen() const; 12 | virtual void onSelButton(); 13 | virtual void onOkButton(); 14 | 15 | virtual const char * getSelButtonText() const; 16 | virtual const char * getOkButtonText() const; 17 | 18 | private: 19 | DebugScreen( const DebugScreen &c ); 20 | DebugScreen& operator=( const DebugScreen &c ); 21 | 22 | uint8_t currentPage; 23 | }; //DebugScreen 24 | 25 | #endif //__DEBUGSCREEN_H__ 26 | -------------------------------------------------------------------------------- /Src/Screens/MemDumpScreen.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "MemDumpScreen.h" 4 | #include "ScreenManager.h" 5 | #include "PrintUtils.h" 6 | 7 | extern Adafruit_SSD1306 display; 8 | 9 | MemDumpScreen::MemDumpScreen() 10 | { 11 | displayAddr = (uint8_t*)0x40005C00; 12 | } 13 | 14 | void MemDumpScreen::drawScreen() const 15 | { 16 | display.setFont(NULL); 17 | 18 | display.setCursor(0,8); 19 | printToDisplay("Addr: %08x", displayAddr); 20 | 21 | display.setCursor(0,16); 22 | uint8_t * addr = displayAddr; 23 | printToDisplay("%02x ", *(addr++)); 24 | printToDisplay("%02x ", *(addr++)); 25 | printToDisplay("%02x ", *(addr++)); 26 | printToDisplay("%02x", *(addr++)); 27 | 28 | display.setCursor(0,24); 29 | printToDisplay("%02x ", *(addr++)); 30 | printToDisplay("%02x ", *(addr++)); 31 | printToDisplay("%02x ", *(addr++)); 32 | printToDisplay("%02x", *(addr++)); 33 | } 34 | 35 | void MemDumpScreen::onSelButton() 36 | { 37 | displayAddr += 8; 38 | } 39 | 40 | void MemDumpScreen::onOkButton() 41 | { 42 | backToParentScreen(); 43 | } 44 | 45 | const char * MemDumpScreen::getSelButtonText() const 46 | { 47 | static const char text[] = "ADDR"; 48 | return text; 49 | } 50 | 51 | const char * MemDumpScreen::getOkButtonText() const 52 | { 53 | static const char text[] = "BACK"; 54 | return text; 55 | } 56 | -------------------------------------------------------------------------------- /Src/Screens/MemDumpScreen.h: -------------------------------------------------------------------------------- 1 | #ifndef MEMDUMPSCREEN_H 2 | #define MEMDUMPSCREEN_H 3 | 4 | #include "Screen.h" 5 | 6 | class MemDumpScreen: public Screen 7 | { 8 | public: 9 | MemDumpScreen(); 10 | 11 | virtual void drawScreen() const; 12 | virtual void onSelButton(); 13 | virtual void onOkButton(); 14 | 15 | virtual const char * getSelButtonText() const; 16 | virtual const char * getOkButtonText() const; 17 | 18 | private: 19 | MemDumpScreen( const MemDumpScreen &c ); 20 | MemDumpScreen& operator=( const MemDumpScreen &c ); 21 | 22 | uint8_t * displayAddr; 23 | }; 24 | 25 | #endif // MEMDUMPSCREEN_H 26 | -------------------------------------------------------------------------------- /Src/Screens/OdometerActionScreen.cpp: -------------------------------------------------------------------------------- 1 | #include "GPS/GPSOdometer.h" 2 | #include "GPS/GPSDataModel.h" 3 | #include "OdometerActionScreen.h" 4 | #include "ScreenManager.h" 5 | 6 | OdometerActionScreen::OdometerActionScreen(uint8_t odometer) 7 | { 8 | odometerID = odometer; 9 | } 10 | 11 | const char * OdometerActionScreen::getItemText(uint8_t idx) const 12 | { 13 | if(idx == 1) 14 | return "Reset"; 15 | 16 | // Assume idx=0 here, so actual text depends on odometer state 17 | GPSOdometerData odometer = GPSDataModel::instance().getOdometerData(odometerID); 18 | 19 | // Active odometer can only be paused 20 | if(odometer.isActive()) 21 | return "Pause"; 22 | 23 | // Inactive is either already paused (and can be resumed) or even not started 24 | if(odometer.getTotalTime() != 0) 25 | return "Resume"; 26 | 27 | return "Start"; 28 | } 29 | 30 | uint8_t OdometerActionScreen::getItemsCount() const 31 | { 32 | return 2; 33 | } 34 | 35 | void OdometerActionScreen::applySelection(uint8_t idx) 36 | { 37 | GPSDataModel & gpsDataModel = GPSDataModel::instance(); 38 | 39 | // Process reset action 40 | if(idx == 1) 41 | { 42 | showMessageBox("Reset"); 43 | gpsDataModel.resetOdometer(odometerID); 44 | return; 45 | } 46 | 47 | // Active odometer can only be paused 48 | if(gpsDataModel.getOdometerData(odometerID).isActive()) 49 | { 50 | showMessageBox("Pause"); 51 | gpsDataModel.pauseOdometer(odometerID); 52 | return; 53 | } 54 | 55 | // Resuming/starting inactive odometer 56 | showMessageBox("Start/Resume"); 57 | gpsDataModel.resumeOdometer(odometerID); 58 | } 59 | -------------------------------------------------------------------------------- /Src/Screens/OdometerActionScreen.h: -------------------------------------------------------------------------------- 1 | #ifndef __ODOMETERACTIONSCREEN_H__ 2 | #define __ODOMETERACTIONSCREEN_H__ 3 | 4 | #include "SelectorScreen.h" 5 | 6 | class OdometerActionScreen: public SelectorScreen 7 | { 8 | uint8_t odometerID; 9 | 10 | public: 11 | OdometerActionScreen(uint8_t odometer); 12 | 13 | protected: 14 | virtual const char * getItemText(uint8_t idx) const; 15 | virtual uint8_t getItemsCount() const; 16 | virtual void applySelection(uint8_t idx); 17 | 18 | private: 19 | OdometerActionScreen( const OdometerActionScreen &c ); 20 | OdometerActionScreen& operator=( const OdometerActionScreen &c ); 21 | }; //OdometerActionScreen 22 | 23 | #endif //__ODOMETERACTIONSCREEN_H__ 24 | -------------------------------------------------------------------------------- /Src/Screens/OdometerScreen.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "GPS/GPSOdometer.h" 5 | #include "GPS/GPSDataModel.h" 6 | 7 | #include "OdometerScreen.h" 8 | #include "SelectorScreen.h" 9 | #include "ScreenManager.h" 10 | #include "TimeFont.h" 11 | #include "8x12Font.h" 12 | #include "PrintUtils.h" 13 | 14 | extern Adafruit_SSD1306 display; 15 | 16 | OdometerScreen::OdometerScreen(uint8_t idx) 17 | : actionSelector(idx) 18 | { 19 | odometerIdx = idx; 20 | inDetailsMode = false; 21 | } 22 | 23 | void OdometerScreen::drawScreen() const 24 | { 25 | if(inDetailsMode) 26 | drawDetailsScreen(); 27 | else 28 | drawBriefScreen(); 29 | } 30 | 31 | void OdometerScreen::drawBriefScreen() const 32 | { 33 | GPSOdometerData odometer = GPSDataModel::instance().getOdometerData(odometerIdx); 34 | 35 | display.setFont(&TimeFont); 36 | display.setCursor(0,31); 37 | 38 | if(odometer.isActive()) 39 | display.print(FloatPrinter(odometer.getOdometerValue(), 4)); 40 | else 41 | display.print("0000"); // TODO: print '----' when there is such symbol in the font 42 | 43 | // Draw distance units 44 | display.setFont(&Monospace8x12Font); // TODO: Use slightly larger bold font 45 | display.setCursor(64, 20); 46 | display.print("km"); 47 | 48 | display.setFont(NULL); 49 | display.setCursor(64,22); 50 | display.print("dH: "); 51 | display.print(FloatPrinter(odometer.getAltitudeDifference(), 4)); 52 | display.print("m"); 53 | } 54 | 55 | void OdometerScreen::drawDetailsScreen() const 56 | { 57 | GPSOdometerData odometer = GPSDataModel::instance().getOdometerData(odometerIdx); 58 | 59 | display.setFont(NULL); 60 | 61 | display.setCursor(0,8); 62 | display.print("Dist: "); 63 | display.print(FloatPrinter(odometer.getOdometerValue(), 4)); 64 | 65 | display.setCursor(64,8); 66 | display.print("dH: "); 67 | display.print(FloatPrinter(odometer.getAltitudeDifference(), 4)); 68 | 69 | display.setCursor(0,16); 70 | display.print("Vavg: "); 71 | display.print(FloatPrinter(odometer.getAvgSpeed(), 4)); 72 | 73 | display.setCursor(64,16); 74 | display.print("Vmax: "); 75 | display.print(FloatPrinter(odometer.getMaxSpeed(), 4)); 76 | 77 | display.setCursor(0,24); 78 | NeoGPS::time_t totalTime(odometer.getTotalTime()); 79 | printToDisplay("T:%02d:%02d:%02d", totalTime.hours, totalTime.minutes, totalTime.seconds); // TODO: This may not fit if total time is more that 1 day 80 | 81 | display.setCursor(64,24); 82 | NeoGPS::time_t activeTime(odometer.getActiveTime()); 83 | printToDisplay("A:%02d:%02d:%02d", activeTime.hours, activeTime.minutes, activeTime.seconds); // TODO: This may not fit if total time is more that 1 day 84 | } 85 | 86 | const char * OdometerScreen::getOkButtonText() const 87 | { 88 | static const char details[] = "DETAILS"; 89 | static const char back[] = "BACK"; 90 | 91 | if(inDetailsMode) 92 | return back; 93 | 94 | return details; 95 | } 96 | 97 | void OdometerScreen::onSelButton() 98 | { 99 | // We will be in brief mode when next time get back to this screen 100 | inDetailsMode = false; 101 | 102 | // Do usual stuff 103 | Screen::onSelButton(); 104 | } 105 | 106 | 107 | void OdometerScreen::onOkButton() 108 | { 109 | // just toggle mode 110 | inDetailsMode = !inDetailsMode; 111 | 112 | if(!inDetailsMode) 113 | enterChildScreen(&actionSelector); 114 | } 115 | -------------------------------------------------------------------------------- /Src/Screens/OdometerScreen.h: -------------------------------------------------------------------------------- 1 | #ifndef __ODOMETERSCREEN_H__ 2 | #define __ODOMETERSCREEN_H__ 3 | 4 | #include "Screen.h" 5 | #include "OdometerActionScreen.h" 6 | 7 | class OdometerScreen : public Screen 8 | { 9 | uint8_t odometerIdx; 10 | bool inDetailsMode; 11 | OdometerActionScreen actionSelector; 12 | 13 | public: 14 | OdometerScreen(uint8_t idx); 15 | 16 | virtual void drawScreen() const; 17 | 18 | virtual const char * getOkButtonText() const; 19 | 20 | virtual void onSelButton(); 21 | virtual void onOkButton(); 22 | 23 | private: 24 | OdometerScreen( const OdometerScreen &c ); 25 | OdometerScreen& operator=( const OdometerScreen &c ); 26 | 27 | void drawBriefScreen() const; 28 | void drawDetailsScreen() const; 29 | }; //OdometerScreen 30 | 31 | #endif //__ODOMETERSCREEN_H__ 32 | -------------------------------------------------------------------------------- /Src/Screens/ParentScreen.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "ParentScreen.h" 3 | #include "ScreenManager.h" 4 | 5 | ParentScreen::ParentScreen() 6 | { 7 | childScreen = NULL; 8 | } 9 | 10 | Screen * ParentScreen::addChildScreen(Screen * screen) 11 | { 12 | childScreen = screen; 13 | return screen; 14 | } 15 | 16 | void ParentScreen::onOkButton() 17 | { 18 | if(childScreen) 19 | enterChildScreen(childScreen); 20 | else 21 | backToParentScreen(); 22 | } -------------------------------------------------------------------------------- /Src/Screens/ParentScreen.h: -------------------------------------------------------------------------------- 1 | #ifndef __PARENTSCREEN_H__ 2 | #define __PARENTSCREEN_H__ 3 | 4 | #include 5 | 6 | #include "Screen.h" 7 | 8 | class ParentScreen : public Screen 9 | { 10 | Screen * childScreen; 11 | 12 | public: 13 | ParentScreen(); 14 | 15 | Screen * addChildScreen(Screen * screen); 16 | 17 | virtual void onOkButton(); 18 | 19 | private: 20 | ParentScreen( const ParentScreen &c ); 21 | ParentScreen& operator=( const ParentScreen &c ); 22 | }; 23 | 24 | #endif //__PARENTSCREEN_H__ 25 | -------------------------------------------------------------------------------- /Src/Screens/SPIDisplayDriver.h: -------------------------------------------------------------------------------- 1 | #ifndef SPIDISPLAYDRIVER_H 2 | #define SPIDISPLAYDRIVER_H 3 | 4 | #include "FreeRTOSHelpers.h" 5 | 6 | #include 7 | #include 8 | 9 | #include 10 | #include 11 | 12 | class SPIDisplayDriver: public ISSD1306Driver 13 | { 14 | // Device handles 15 | SPI_HandleTypeDef spiHandle; 16 | DMA_HandleTypeDef dmaHandleTx; 17 | 18 | // transfer synchronization object 19 | Sema sema; 20 | 21 | public: 22 | SPIDisplayDriver(); 23 | 24 | virtual void begin(); 25 | virtual void startTransaction(); 26 | virtual void sendCommand(uint8_t cmd); 27 | virtual void sendCommands(const uint8_t *cmds, size_t size); 28 | virtual void sendData(const uint8_t * data, size_t size); 29 | virtual void endTransaction(); 30 | 31 | // Handle getter 32 | SPI_HandleTypeDef getHandle() const {return spiHandle;} 33 | 34 | // DMA transter callback 35 | void dmaTransferCompletedCB(); 36 | }; 37 | 38 | #endif // SPIDISPLAYDRIVER_H 39 | -------------------------------------------------------------------------------- /Src/Screens/SatellitesScreen.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "SatellitesScreen.h" 6 | #include "8x12Font.h" 7 | #include "PrintUtils.h" 8 | 9 | #include "GPS/GPSDataModel.h" 10 | 11 | // DebugScreen should not be here. I just needed to attach DebugScreen somewhere 12 | #include "DebugScreen.h" 13 | #include "MemDumpScreen.h" 14 | DebugScreen debugScreen; 15 | MemDumpScreen dumpScreen; 16 | 17 | extern Adafruit_SSD1306 display; 18 | 19 | SatellitesScreen::SatellitesScreen() 20 | { 21 | addChildScreen(&debugScreen); 22 | } 23 | 24 | void SatellitesScreen::drawScreen() const 25 | { 26 | GPSSatellitesData satellites = GPSDataModel::instance().getSattelitesData(); 27 | 28 | // Draw a bar on each satellites in the list 29 | uint8_t width = 3; 30 | uint8_t tracked = 0; 31 | uint8_t sat_count = satellites.getSattelitesCount(); 32 | for(uint8_t sat = 0; sat < sat_count; sat++) 33 | { 34 | uint8_t x = display.width() / 2 + sat * width; 35 | uint8_t snr = satellites.getSatteliteSNR(sat); 36 | if (snr > 50) // Cap value with 50 dBm 37 | snr = 50; 38 | uint8_t h = (float)snr * 22 / 50; // TODO: Remove hardcoded numbers. 22 is max height for a bar, 50 is max dBm 39 | display.fillRect(x, display.height() - h, width - 1, h, 1); 40 | 41 | // Draw a short stroke above the tracked satellite bar 42 | if (satellites.isSatteliteTracked(sat)) 43 | { 44 | display.drawFastHLine(x, 9, width - 1, 1); 45 | tracked++; 46 | } 47 | } 48 | 49 | // other stuff 50 | uint8_t sat_count_local = sat_count; 51 | gps_fix gpsFix = GPSDataModel::instance().getGPSFix(); 52 | gps_fix::status_t status = gpsFix.status; 53 | 54 | // Drawing stats 55 | display.setFont(NULL); 56 | display.setCursor(0,8); 57 | display.print("Sats: "); 58 | display.print(tracked); 59 | display.print("/"); 60 | display.println(sat_count_local); 61 | if(gpsFix.valid.hdop) 62 | display.print(FloatPrinter(gpsFix.hdop/1000, 4)); 63 | else 64 | display.print("----"); 65 | display.print(" "); 66 | if(gpsFix.valid.vdop) 67 | display.println(FloatPrinter(gpsFix.vdop/1000, 4)); 68 | else 69 | display.println("----"); 70 | display.print("St: "); 71 | static const char * statuses[] = {"NONE", "EST", "TIME", "STD", "DGPS"}; 72 | display.println(statuses[status]); 73 | } 74 | -------------------------------------------------------------------------------- /Src/Screens/SatellitesScreen.h: -------------------------------------------------------------------------------- 1 | #ifndef __SATELLITESSCREEN_H__ 2 | #define __SATELLITESSCREEN_H__ 3 | 4 | #include "ParentScreen.h" 5 | 6 | class SatellitesScreen : public ParentScreen // TODO: This should inherit Screen, not ParentScreen. I just needed to attach DebugScreen somewhere 7 | { 8 | public: 9 | SatellitesScreen(); 10 | 11 | virtual void drawScreen() const; 12 | 13 | private: 14 | SatellitesScreen( const SatellitesScreen &c ); 15 | SatellitesScreen& operator=( const SatellitesScreen &c ); 16 | 17 | }; //SatellitesScreen 18 | 19 | #endif //__SATELLITESSCREEN_H__ 20 | -------------------------------------------------------------------------------- /Src/Screens/Screen.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | #include "Screen.h" 6 | #include "ScreenManager.h" 7 | 8 | extern Adafruit_SSD1306 display; 9 | 10 | Screen::Screen() 11 | { 12 | nextScreen = this; 13 | } 14 | 15 | void Screen::drawHeader() const 16 | { 17 | display.setFont(NULL); 18 | display.setCursor(16, 0); 19 | display.print('\x1e'); 20 | display.print(getSelButtonText()); 21 | 22 | display.setCursor(70, 0); 23 | display.print('\x1e'); 24 | display.print(getOkButtonText()); 25 | } 26 | 27 | void Screen::onSelButton() 28 | { 29 | setCurrentScreen(nextScreen); 30 | } 31 | 32 | void Screen::onOkButton() 33 | { 34 | //nothing by default. implemented in derived classes 35 | } 36 | 37 | Screen * Screen::addScreen(Screen * screen) 38 | { 39 | screen->nextScreen = nextScreen; 40 | nextScreen = screen; 41 | return screen; 42 | } 43 | 44 | const char * Screen::getSelButtonText() const 45 | { 46 | static const char text[] = "MODE"; 47 | return text; 48 | } 49 | 50 | const char * Screen::getOkButtonText() const 51 | { 52 | static const char text[] = "ENTER"; 53 | return text; 54 | } 55 | -------------------------------------------------------------------------------- /Src/Screens/Screen.h: -------------------------------------------------------------------------------- 1 | #ifndef _SCREEN_H_ 2 | #define _SCREEN_H_ 3 | 4 | class Adafruit_SSD1306; 5 | extern Adafruit_SSD1306 display; 6 | 7 | class Screen 8 | { 9 | Screen * nextScreen; 10 | 11 | public: 12 | Screen(); 13 | //virtual ~Screen() {} //Virtual destructor is intentionally commented as it consumes a lot of RAM/FLASH but will never called 14 | 15 | virtual void drawScreen() const = 0; 16 | virtual void drawHeader() const; 17 | virtual void onSelButton(); 18 | virtual void onOkButton(); 19 | 20 | virtual const char * getSelButtonText() const; 21 | virtual const char * getOkButtonText() const; 22 | 23 | Screen * addScreen(Screen * screen); 24 | }; 25 | 26 | 27 | #endif //_SCREEN_H_ 28 | -------------------------------------------------------------------------------- /Src/Screens/ScreenManager.h: -------------------------------------------------------------------------------- 1 | #ifndef __SCREENMANAGER_H__ 2 | #define __SCREENMANAGER_H__ 3 | 4 | // Forward declarations 5 | class Screen; 6 | 7 | /// Set current screen to display 8 | void setCurrentScreen(Screen * screen); 9 | /// Retrieve currently set screen 10 | Screen * getCurrentScreen(); 11 | 12 | /// Enter into a nested screen (previous screen is saved in screen stack) 13 | void enterChildScreen(Screen * screen); 14 | /// Return to a parent screen stored in stack 15 | void backToParentScreen(); 16 | 17 | /// Initialize display stuff 18 | void initDisplay(); 19 | /// Initialize screens and their relationship 20 | void initScreens(); 21 | /// Draw current screen 22 | void drawDisplay(); 23 | /// Show a message box 24 | void showMessageBox(const char * text); 25 | 26 | /// Display thread. Responsible for displaying an actual screen and handle messages from buttons thread 27 | void vDisplayTask(void *pvParameters); 28 | 29 | #endif //__SCREENMANAGER_H__ 30 | -------------------------------------------------------------------------------- /Src/Screens/SelectorScreen.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "8x12Font.h" 4 | #include "SelectorScreen.h" 5 | #include "ScreenManager.h" 6 | 7 | extern Adafruit_SSD1306 display; 8 | 9 | SelectorScreen::SelectorScreen() 10 | { 11 | currentIdx = 0; 12 | } 13 | 14 | void SelectorScreen::drawScreen() const 15 | { 16 | display.setFont(&Monospace8x12Font); 17 | if(currentIdx != getItemsCount()) 18 | drawCentered(getItemText(currentIdx), 26); 19 | else 20 | drawCentered("Back", 26); 21 | } 22 | 23 | void SelectorScreen::drawCentered(const char * str, uint8_t y) const 24 | { 25 | uint8_t x = display.width() / 2 - strlen(str) * 8 / 2; 26 | display.setCursor(x, y); 27 | display.print(str); 28 | } 29 | 30 | void SelectorScreen::onSelButton() 31 | { 32 | currentIdx++; 33 | currentIdx %= (getItemsCount() + 1); // +1 to account 'Back' value 34 | } 35 | 36 | void SelectorScreen::onOkButton() 37 | { 38 | // Perform an action associated with selected item 39 | if(currentIdx < getItemsCount()) 40 | applySelection(currentIdx); 41 | 42 | // Reset the index so user starts from the beginning next time 43 | currentIdx = 0; 44 | 45 | // Back to previous screen 46 | backToParentScreen(); 47 | } 48 | 49 | const char * SelectorScreen::getSelButtonText() const 50 | { 51 | static const char text[] = "NEXT"; 52 | return text; 53 | } 54 | 55 | const char * SelectorScreen::getOkButtonText() const 56 | { 57 | static const char text[] = "OK"; 58 | return text; 59 | } 60 | -------------------------------------------------------------------------------- /Src/Screens/SelectorScreen.h: -------------------------------------------------------------------------------- 1 | #ifndef __SELECTORSCREEN_H__ 2 | #define __SELECTORSCREEN_H__ 3 | 4 | #include "Screen.h" 5 | 6 | /// Selector Screen is a base class for screens that provides user with number of options to select. 7 | /// The class implements iteration over items and displaying items text. Class does not handle items themselves. 8 | /// That is because items may be generated in runtime by a class-ancestor 9 | class SelectorScreen: public Screen 10 | { 11 | uint8_t currentIdx; 12 | 13 | public: 14 | SelectorScreen(); 15 | 16 | virtual void drawScreen() const; 17 | 18 | virtual const char * getOkButtonText() const; 19 | virtual const char * getSelButtonText() const; 20 | 21 | virtual void onSelButton(); 22 | virtual void onOkButton(); 23 | 24 | protected: 25 | virtual const char * getItemText(uint8_t idx) const = 0; 26 | virtual uint8_t getItemsCount() const = 0; 27 | virtual void applySelection(uint8_t idx) = 0; 28 | 29 | private: 30 | SelectorScreen( const SelectorScreen &c ); 31 | SelectorScreen& operator=( const SelectorScreen &c ); 32 | 33 | void drawCentered(const char * str, uint8_t y) const; 34 | 35 | }; //SelectorScreen 36 | 37 | #endif //__SELECTORSCREEN_H__ 38 | -------------------------------------------------------------------------------- /Src/Screens/SettingsGroupScreen.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "8x12Font.h" 4 | #include "SettingsGroupScreen.h" 5 | 6 | extern Adafruit_SSD1306 display; 7 | 8 | SettingsGroupScreen::SettingsGroupScreen() 9 | { 10 | } 11 | 12 | void SettingsGroupScreen::drawScreen() const 13 | { 14 | display.setFont(&Monospace8x12Font); 15 | drawCentered("Settings", 26); 16 | } 17 | 18 | void SettingsGroupScreen::drawCentered(const char * str, uint8_t y) const 19 | { 20 | uint8_t x = display.width() / 2 - strlen(str) * 8 / 2; 21 | display.setCursor(x, y); 22 | display.print(str); 23 | } 24 | -------------------------------------------------------------------------------- /Src/Screens/SettingsGroupScreen.h: -------------------------------------------------------------------------------- 1 | #ifndef __SettingsGroupScreen_H__ 2 | #define __SettingsGroupScreen_H__ 3 | 4 | #include "Screen.h" 5 | 6 | class SettingsGroupScreen: public Screen 7 | { 8 | public: 9 | SettingsGroupScreen(); 10 | 11 | virtual void drawScreen() const; 12 | 13 | 14 | private: 15 | SettingsGroupScreen( const SettingsGroupScreen &c ); 16 | SettingsGroupScreen& operator=( const SettingsGroupScreen &c ); 17 | 18 | void drawCentered(const char * str, uint8_t y) const; 19 | 20 | }; //SettingsGroupScreen 21 | 22 | #endif //__SettingsGroupScreen_H__ 23 | -------------------------------------------------------------------------------- /Src/Screens/SpeedScreen.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "SpeedScreen.h" 5 | #include "AltitudeScreen.h" 6 | #include "TimeFont.h" 7 | #include "8x12Font.h" 8 | #include "PrintUtils.h" 9 | 10 | #include "GPS/GPSDataModel.h" 11 | 12 | 13 | extern Adafruit_SSD1306 display; 14 | 15 | AltitudeScreen altitudeScreen; 16 | 17 | SpeedScreen::SpeedScreen() 18 | { 19 | addChildScreen(&altitudeScreen); 20 | } 21 | 22 | void SpeedScreen::drawScreen() const 23 | { 24 | // Get the gps fix data 25 | gps_fix gpsFix = GPSDataModel::instance().getGPSFix(); 26 | 27 | // Draw speed 28 | // TODO draw '----' if no GPS signal found. Requires new character in font 29 | char buf[7]; // 6 symbols + trailing zero 30 | strcpy(buf, "----"); 31 | printNumber(buf, gpsFix.speed_kph(), 4, true); // TODO: Add leading spaces 32 | display.setFont(&TimeFont); 33 | display.setCursor(24,31); 34 | display.print(buf); 35 | 36 | // Draw speed units 37 | display.setFont(&Monospace8x12Font); // TODO: Use slightly larger bold font 38 | display.setCursor(90, 20); 39 | display.print("km/h"); 40 | 41 | // Draw altitude 42 | strcpy(buf, "-----m"); 43 | if(gpsFix.valid.altitude) 44 | { 45 | if(gpsFix.alt.whole >= 0) 46 | printNumber(buf, gpsFix.alt.whole, 5); 47 | else 48 | printNumber(buf+1, abs(gpsFix.alt.whole), 4); // there could be negative altitude 49 | } 50 | display.setFont(NULL); 51 | display.setCursor(90, 24); 52 | display.print(buf); 53 | 54 | // Draw heading letter 55 | display.setFont(&Monospace8x12Font); // TODO: Use slightly larger bold font 56 | display.setCursor(2, 20); 57 | if(gpsFix.valid.heading) 58 | display.print(headingAsLetter(gpsFix.hdg.whole)); 59 | else 60 | display.print("--"); 61 | 62 | // Draw heading value 63 | strcpy(buf, "---'"); 64 | if(gpsFix.valid.heading) 65 | printNumber(buf, gpsFix.hdg.whole, 3); 66 | display.setFont(NULL); 67 | display.setCursor(0, 24); 68 | display.print(buf); 69 | } 70 | 71 | const char * SpeedScreen::headingAsLetter(uint16_t heading) 72 | { 73 | if(heading < 22) 74 | return "N"; 75 | if(heading < 67) 76 | return "NE"; 77 | if(heading < 122) 78 | return "E"; 79 | if(heading < 157) 80 | return "SE"; 81 | if(heading < 202) 82 | return "S"; 83 | if(heading < 247) 84 | return "SW"; 85 | if(heading < 292) 86 | return "W"; 87 | if(heading < 337) 88 | return "NW"; 89 | 90 | return "N"; 91 | } 92 | 93 | const char * SpeedScreen::getOkButtonText() const 94 | { 95 | static const char text[] = "ALTITUDE"; 96 | return text; 97 | } 98 | -------------------------------------------------------------------------------- /Src/Screens/SpeedScreen.h: -------------------------------------------------------------------------------- 1 | #ifndef __SPEEDSCREEN_H__ 2 | #define __SPEEDSCREEN_H__ 3 | 4 | #include "ParentScreen.h" 5 | 6 | class SpeedScreen : public ParentScreen 7 | { 8 | public: 9 | SpeedScreen(); 10 | 11 | virtual void drawScreen() const; 12 | 13 | virtual const char * getOkButtonText() const; 14 | 15 | static const char * headingAsLetter(uint16_t heading); 16 | 17 | private: 18 | SpeedScreen( const SpeedScreen &c ); 19 | SpeedScreen& operator=( const SpeedScreen &c ); 20 | }; //SpeedScreen 21 | 22 | #endif //__SPEEDSCREEN_H__ 23 | -------------------------------------------------------------------------------- /Src/Screens/TimeZoneScreen.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "TimeZoneScreen.h" 5 | #include "ScreenManager.h" 6 | #include "TimeFont.h" 7 | #include "PrintUtils.h" 8 | 9 | #include "GPS/GPSDataModel.h" 10 | 11 | extern Adafruit_SSD1306 display; 12 | 13 | const int16_t timeZones[] = 14 | { 15 | 0 * 60 + 00, // +00:00 16 | 1 * 60 + 00, // +01:00 17 | 2 * 60 + 00, // +02:00 18 | 3 * 60 + 00, // +03:00 19 | 3 * 60 + 30, // +03:30 20 | 4 * 60 + 00, // +04:00 21 | 4 * 60 + 30, // +04:30 22 | 5 * 60 + 00, // +05:00 23 | 5 * 60 + 30, // +05:30 24 | 5 * 60 + 45, // +05:45 25 | 6 * 60 + 00, // +06:00 26 | 6 * 60 + 30, // +06:30 27 | 7 * 60 + 00, // +07:00 28 | 8 * 60 + 00, // +08:00 29 | 9 * 60 + 00, // +09:00 30 | 9 * 60 + 30, // +09:30 31 | 10 * 60 + 00, // +10:00 32 | 11 * 60 + 00, // +11:00 33 | 12 * 60 + 00, // +12:00 34 | 13 * 60 + 00, // +13:00 35 | 36 | -12 * 60 - 00, // -12:00 37 | -11 * 60 - 00, // -11:00 38 | -10 * 60 - 00, // -10:00 39 | -9 * 60 - 00, // -09:00 40 | -8 * 60 - 00, // -08:00 41 | -7 * 60 - 00, // -07:00 42 | -6 * 60 - 00, // -06:00 43 | -5 * 60 - 00, // -05:00 44 | -4 * 60 - 30, // -04:30 45 | -4 * 60 - 00, // -04:00 46 | -3 * 60 - 30, // -03:30 47 | -3 * 60 - 00, // -03:00 48 | -2 * 60 - 00, // -02:00 49 | -1 * 60 - 00 // -01:00 50 | }; 51 | 52 | 53 | TimeZoneScreen::TimeZoneScreen() 54 | { 55 | timeZoneIdx = 2; // TODO: get the value in settings EEPROM 56 | } 57 | 58 | void TimeZoneScreen::drawScreen() const 59 | { 60 | // Get the date/time adjusted by selected timezone value 61 | gps_fix gpsFix = GPSDataModel::instance().getGPSFix(); 62 | int16_t timeZone = getCurrentTimeZone(); 63 | NeoGPS::time_t dateTime = gpsFix.dateTime + timeZone * 60; //timeZone is in minutes 64 | 65 | // Draw the time string 66 | display.setFont(&TimeFont); 67 | display.setCursor(0,31); 68 | printToDisplay("%02d:%02d", dateTime.hours, dateTime.minutes); 69 | 70 | // Draw the date and time zone strings 71 | display.setFont(nullptr); 72 | display.setCursor(78,8); 73 | printToDisplay("%02d/%02d/%02d", dateTime.date, dateTime.month, dateTime.year); 74 | 75 | display.setCursor(78,16); 76 | display.print(" UTC"); 77 | 78 | display.setCursor(78,24); 79 | display.print(timeZone < 0 ? '-' : '+'); // TODO implement char printing for printf 80 | printToDisplay("%02d:%02d", abs(timeZone) / 60, abs(timeZone) % 60); 81 | } 82 | 83 | void TimeZoneScreen::onSelButton() 84 | { 85 | timeZoneIdx++; 86 | timeZoneIdx %= sizeof(timeZones) / sizeof(timeZones[0]); 87 | } 88 | 89 | void TimeZoneScreen::onOkButton() 90 | { 91 | //TODO: Apply time zone here and store it to Settings/EEPROM 92 | 93 | //TODO: consider handling a long press as a cancel operation 94 | 95 | backToParentScreen(); 96 | } 97 | 98 | const char * TimeZoneScreen::getSelButtonText() const 99 | { 100 | static const char text[] = "SELECT"; 101 | return text; 102 | } 103 | 104 | const char * TimeZoneScreen::getOkButtonText() const 105 | { 106 | static const char text[] = "OK"; 107 | return text; 108 | } 109 | 110 | int16_t TimeZoneScreen::getCurrentTimeZone() const 111 | { 112 | return timeZones[timeZoneIdx]; 113 | } 114 | -------------------------------------------------------------------------------- /Src/Screens/TimeZoneScreen.h: -------------------------------------------------------------------------------- 1 | #ifndef TIMEZONESCREEN_H_ 2 | #define TIMEZONESCREEN_H_ 3 | 4 | #include "Screen.h" 5 | 6 | #include 7 | 8 | class TimeZoneScreen : public Screen 9 | { 10 | public: 11 | TimeZoneScreen(); 12 | 13 | virtual void drawScreen() const; 14 | virtual void onSelButton(); 15 | virtual void onOkButton(); 16 | 17 | virtual const char * getSelButtonText() const; 18 | virtual const char * getOkButtonText() const; 19 | 20 | //returns time zone as a number of minutes to add/substract from GPS time 21 | int16_t getCurrentTimeZone() const; 22 | 23 | private: 24 | TimeZoneScreen( const TimeZoneScreen &c ); 25 | TimeZoneScreen& operator=( const TimeZoneScreen &c ); 26 | 27 | // An index in a list of time zones 28 | uint8_t timeZoneIdx; 29 | }; //TimeZoneScreen 30 | 31 | #endif //TIMEZONESCREEN_H_ 32 | -------------------------------------------------------------------------------- /Src/SdFatSPIDriver.h: -------------------------------------------------------------------------------- 1 | #ifndef SDFATSPIDRIVER_H 2 | #define SDFATSPIDRIVER_H 3 | 4 | #include "SpiDriver/SdSpiBaseDriver.h" 5 | 6 | #include 7 | 8 | //Forward declarations 9 | class SPISettings; 10 | typedef void * SemaphoreHandle_t; 11 | 12 | // This is custom implementation of SPI Driver class. SdFat library is 13 | // using this class to access SD card over SPI 14 | // 15 | // Main intention of this implementation is to drive data transfer 16 | // over DMA and synchronize with FreeRTOS capabilities. 17 | 18 | class SdFatSPIDriver : public SdSpiBaseDriver 19 | { 20 | // SPI module 21 | SPI_HandleTypeDef spiHandle; 22 | DMA_HandleTypeDef dmaHandleRx; 23 | DMA_HandleTypeDef dmaHandleTx; 24 | 25 | // Synchronization semaphore handle 26 | SemaphoreHandle_t xSema = NULL; 27 | 28 | public: 29 | SdFatSPIDriver(); 30 | 31 | virtual void activate(); 32 | virtual void begin(uint8_t chipSelectPin); 33 | virtual void deactivate(); 34 | virtual uint8_t receive(); 35 | virtual uint8_t receive(uint8_t* buf, size_t n); 36 | virtual void send(uint8_t data); 37 | virtual void send(const uint8_t* buf, size_t n); 38 | virtual void select(); 39 | virtual void setSpiSettings(const SPISettings & spiSettings); 40 | virtual void unselect(); 41 | 42 | // Handle getter 43 | SPI_HandleTypeDef getHandle() const {return spiHandle;} 44 | 45 | // DMA transter callback 46 | void dmaTransferCompletedCB(); 47 | }; 48 | 49 | 50 | #endif //SDFATSPIDRIVER_H 51 | -------------------------------------------------------------------------------- /Src/SdMscDriver.h: -------------------------------------------------------------------------------- 1 | #ifndef SDMSCDRIVER_H 2 | #define SDMSCDRIVER_H 3 | 4 | #include "usbd_msc.h" 5 | 6 | bool initSDIOThread(); 7 | void xSDIOThread(void *pvParameters); 8 | void xSDTestThread(void *pvParameters); 9 | 10 | extern USBD_StorageTypeDef SdMscDriver; 11 | 12 | #endif // SDMSCDRIVER_H 13 | -------------------------------------------------------------------------------- /Src/SerialDebugLogger.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include // strlen 6 | #include // VA 7 | 8 | #include "SerialDebugLogger.h" 9 | #include "PrintUtils.h" 10 | 11 | 12 | 13 | void initDebugSerial() 14 | { 15 | // Enable clocking of corresponding periperhal 16 | __HAL_RCC_GPIOA_CLK_ENABLE(); 17 | __HAL_RCC_USART2_CLK_ENABLE(); 18 | 19 | // Init pins in alternate function mode 20 | LL_GPIO_SetPinMode(GPIOA, LL_GPIO_PIN_2, LL_GPIO_MODE_ALTERNATE); //TX pin 21 | LL_GPIO_SetPinSpeed(GPIOA, LL_GPIO_PIN_2, LL_GPIO_SPEED_FREQ_HIGH); 22 | LL_GPIO_SetPinOutputType(GPIOA, LL_GPIO_PIN_2, LL_GPIO_OUTPUT_PUSHPULL); 23 | 24 | LL_GPIO_SetPinMode(GPIOA, LL_GPIO_PIN_3, LL_GPIO_MODE_INPUT); //RX pin 25 | 26 | // Prepare for initialization 27 | LL_USART_Disable(USART2); 28 | 29 | // Init 30 | LL_USART_SetBaudRate(USART2, HAL_RCC_GetPCLK1Freq(), 115200*8); 31 | LL_USART_SetDataWidth(USART2, LL_USART_DATAWIDTH_8B); 32 | LL_USART_SetStopBitsLength(USART2, LL_USART_STOPBITS_1); 33 | LL_USART_SetParity(USART2, LL_USART_PARITY_NONE); 34 | LL_USART_SetTransferDirection(USART2, LL_USART_DIRECTION_TX_RX); 35 | LL_USART_SetHWFlowCtrl(USART2, LL_USART_HWCONTROL_NONE); 36 | 37 | // Finally enable the peripheral 38 | LL_USART_Enable(USART2); 39 | 40 | serialDebugWrite("\n\n\n\n=================================================\n\n\n\n"); 41 | } 42 | 43 | struct SerialTarget: public PrintTarget 44 | { 45 | virtual void operator()(char c) 46 | { 47 | if(c != '\0') 48 | { 49 | while (!LL_USART_IsActiveFlag_TXE(USART2)) 50 | ; 51 | 52 | LL_USART_TransmitData8(USART2, c); 53 | } 54 | } 55 | }; 56 | 57 | extern "C" void serialDebugWrite(const char * fmt, ...) 58 | { 59 | va_list args; 60 | va_start(args, fmt); 61 | SerialTarget target; 62 | print(target, fmt, args); 63 | va_end(args); 64 | } 65 | 66 | extern "C" void serialDebugWriteC(char c) 67 | { 68 | SerialTarget target; 69 | target(c); 70 | } 71 | 72 | -------------------------------------------------------------------------------- /Src/SerialDebugLogger.h: -------------------------------------------------------------------------------- 1 | #ifndef SERIALDEBUGLOGGER_H 2 | #define SERIALDEBUGLOGGER_H 3 | 4 | #include 5 | #include 6 | 7 | void initDebugSerial(); 8 | void serialDebugWrite(char c); 9 | extern "C" void serialDebugWrite(const char * fmt, ...); 10 | extern "C" void serialDebugWriteC(char c); 11 | 12 | 13 | #endif // SERIALDEBUGLOGGER_H 14 | -------------------------------------------------------------------------------- /Src/Thread.h: -------------------------------------------------------------------------------- 1 | #ifndef THREAD_H 2 | #define THREAD_H 3 | 4 | #include 5 | #include 6 | 7 | template 8 | class Thread 9 | { 10 | protected: 11 | StaticTask_t xTaskControlBlock; 12 | StackType_t xStack[ ulStackDepth ]; 13 | 14 | public: 15 | Thread(TaskFunction_t pxTaskCode, 16 | const char * const pcName, 17 | void * const pvParameters, 18 | UBaseType_t uxPriority) 19 | { 20 | xTaskCreateStatic(pxTaskCode, pcName, ulStackDepth, pvParameters, uxPriority, xStack, &xTaskControlBlock); 21 | } 22 | }; 23 | 24 | #endif // THREAD_H 25 | -------------------------------------------------------------------------------- /Src/TimeFont.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | // This font is based on Bodoni MT 24pt, slightly corrected in picture editor 4 | extern const GFXfont TimeFont; -------------------------------------------------------------------------------- /Src/USBDebugLogger.h: -------------------------------------------------------------------------------- 1 | #ifndef USBDEBUGLOGGER_H 2 | #define USBDEBUGLOGGER_H 3 | 4 | #include 5 | #include 6 | 7 | void initUSB(); 8 | void usbDebugWrite(char c); 9 | void usbDebugWrite(const char * fmt, ...); 10 | 11 | #endif // USBDEBUGLOGGER_H 12 | -------------------------------------------------------------------------------- /cmake/README.md: -------------------------------------------------------------------------------- 1 | # Files origin 2 | 3 | Files in this folder originally taken from https://github.com/ObKo/stm32-cmake with minor modifications. 4 | Only 2 files are used from the original project 5 | 6 | # Changes details 7 | 8 | These files have compiler flags fine tuned for GPS Logger project in order to reduce resulting firmware size. 9 | 10 | 11 | # TODOs 12 | 13 | I had to remove -flto flag from compiler and linker switches as Arduino/stm32duino sources do not compile with this flag. 14 | Obviously this is a helpful option that needs attention later --------------------------------------------------------------------------------