From 321cb55da091a79762f25ba748d87f08089630a2 Mon Sep 17 00:00:00 2001 From: StefanSch Date: Tue, 19 Mar 2019 18:12:01 +0100 Subject: [PATCH] added support to put LCD data to FRAM --- .../LCD_SharpBoosterPack_SPI.cpp | 58 +++++++++++-------- .../LCD_SharpBoosterPack_SPI.h | 10 ++-- 2 files changed, 40 insertions(+), 28 deletions(-) diff --git a/libraries/LCD_SharpBoosterPack_SPI/LCD_SharpBoosterPack_SPI.cpp b/libraries/LCD_SharpBoosterPack_SPI/LCD_SharpBoosterPack_SPI.cpp index 86c68118fc9..5bd731eac83 100644 --- a/libraries/LCD_SharpBoosterPack_SPI/LCD_SharpBoosterPack_SPI.cpp +++ b/libraries/LCD_SharpBoosterPack_SPI/LCD_SharpBoosterPack_SPI.cpp @@ -3,14 +3,15 @@ // Example for library for Sharp BoosterPack LCD with hardware SPI // // -// Author : Stefan Schauer +// Author : StefanSch // Date : Mar 05, 2015 -// Version: 1.03 +// Version: 1.04 // File : LCD_SharpBoosterPack_SPI_main.c // // Version: 1.01 : added support for CC3200 // Version: 1.02 : added print class // Version: 1.03 : added support for Sharp 128 +// Version: 1.04 : added support for Data in FRAM // // Based on the LCD5110 Library // Created by Rei VILO on 28/05/12 @@ -26,6 +27,9 @@ // Added flushReversed() for reversed display and preserved buffer // Simplified Clear function // +// Edited 2019-03-19 by StefaSch +// Added support for smaller memory with put LCD data to FRAM +// #include #include "LCD_SharpBoosterPack_SPI.h" @@ -38,13 +42,16 @@ uint8_t _pinVCC; uint8_t _pinChipSelect; uint8_t _pinSerialClock; bool _autoVCOM; +uint8_t lcd_vertical_max; +uint8_t lcd_horizontal_max; + // Booster Pack Pins -// 7 - P2.2 for SPI_CLK mode -// 15 - P1.6 for SPI_SIMO mode -// 6 - P2.4 output pin for SPI_CS -// 2 - P4.2 as output to supply the LCD -// 5 - P4.3 as output for DISP +// 7 - SPI_CLK mode +// 15 - SPI_SIMO mode +// 6 - output pin for SPI_CS +// 2 - output to supply the LCD +// 5 - output for DISP // Set display's VCC and DISP pins to high @@ -68,6 +75,7 @@ unsigned char flagSendToggleVCOMCommand = 0; #define SHARP_REQUEST_TOGGLE_VCOM 0x02 + static void SendToggleVCOMCommand(void); uint8_t textx = 0; @@ -83,36 +91,40 @@ uint16_t LCD_SharpBoosterPack_SPI::_index(uint8_t x, uint8_t y) LCD_SharpBoosterPack_SPI::LCD_SharpBoosterPack_SPI(uint8_t model) { - _pinChipSelect = P_CS; - _pinDISP = P_DISP; - _pinVCC = P_VCC; - _autoVCOM = true; - - lcd_vertical_max = model; - lcd_horizontal_max = model; + LCD_SharpBoosterPack_SPI(P_CS, P_DISP, P_VCC, true, model); +} - static uint8_t * _frameBuffer; - _frameBuffer = new uint8_t[_index(lcd_vertical_max, lcd_horizontal_max)]; - DisplayBuffer = (uint8_t *) _frameBuffer; +LCD_SharpBoosterPack_SPI::LCD_SharpBoosterPack_SPI(uint8_t pinChipSelect, uint8_t pinDISP, uint8_t pinVCC, uint8_t model) +{ + LCD_SharpBoosterPack_SPI(pinChipSelect, pinDISP, pinVCC, true, model); } -LCD_SharpBoosterPack_SPI::LCD_SharpBoosterPack_SPI(uint8_t pinChipSelect, uint8_t pinDISP, uint8_t pinVCC, bool autoVCOM, uint8_t model) +#ifdef PLACE_IN_FRAM + uint8_t _frameBuffer[128][128/8] PLACE_IN_FRAM; +#else + uint8_t * _frameBuffer = 0; +#endif + +LCD_SharpBoosterPack_SPI::LCD_SharpBoosterPack_SPI(uint8_t pinChipSelect, uint8_t pinDISP, uint8_t pinVCC, bool autoVCOM, uint8_t model) { + _pinChipSelect = pinChipSelect; _pinDISP = pinDISP; _pinVCC = pinVCC; _autoVCOM = autoVCOM; - digitalWrite(RED_LED, HIGH); lcd_vertical_max = model; lcd_horizontal_max = model; -} -LCD_SharpBoosterPack_SPI::LCD_SharpBoosterPack_SPI(uint8_t pinChipSelect, uint8_t pinDISP, uint8_t pinVCC, uint8_t model) -{ - LCD_SharpBoosterPack_SPI(pinChipSelect, pinDISP, pinVCC, true, model); +#ifndef PLACE_IN_FRAM + if (_frameBuffer == 0){ + _frameBuffer = new uint8_t[_index(lcd_vertical_max, lcd_horizontal_max)]; + } +#endif + DisplayBuffer = (uint8_t *) _frameBuffer; } + void LCD_SharpBoosterPack_SPI::setOrientation(uint8_t orientation) { _orientation = orientation % 4; diff --git a/libraries/LCD_SharpBoosterPack_SPI/LCD_SharpBoosterPack_SPI.h b/libraries/LCD_SharpBoosterPack_SPI/LCD_SharpBoosterPack_SPI.h index 6058406162a..0e5772ed283 100644 --- a/libraries/LCD_SharpBoosterPack_SPI/LCD_SharpBoosterPack_SPI.h +++ b/libraries/LCD_SharpBoosterPack_SPI/LCD_SharpBoosterPack_SPI.h @@ -3,9 +3,9 @@ // Example for library for Sharp BoosterPack LCD 96 and 128 with hardware SPI // // -// Author : Stefan Schauer +// Author : StefanSch // Date : Mar 05, 2015 -// Version: 1.02 +// Version: 1.03 // File : LCD_SharpBoosterPack_SPI_main.h // // Based on the LCD5110 Library @@ -21,6 +21,9 @@ // Added support for Sharp 128 with minimal change // Added flushReversed() for reversed display and preserved buffer // +// Edited 2019-03-19 by StefaSch +// Added support for smaller memory with put LCD data to FRAM +// #ifndef LCD_SharpBoosterPack_SPI_h #define LCD_SharpBoosterPack_SPI_h @@ -72,7 +75,6 @@ class LCD_SharpBoosterPack_SPI : public Print /// @param pinVCC VCC pin /// @param model default=SHARP_96 for compatibility, SHARP_128 /// - /// @note For SensorTag CC2650 /// @code /// LCD_SharpBoosterPack_SPI myScreen(7, 10, 1, SHARP_96); /// LCD_SharpBoosterPack_SPI myScreen(7, 10, 1, true, SHARP_128); @@ -173,8 +175,6 @@ class LCD_SharpBoosterPack_SPI : public Print void TA0_turnOff(); uint8_t _orientation; bool _reverse; - uint8_t lcd_vertical_max; - uint8_t lcd_horizontal_max; }; #endif