Skip to content

Commit

Permalink
added support to put LCD data to FRAM
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanSch committed Mar 19, 2019
1 parent 3f3eca8 commit 321cb55
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 28 deletions.
58 changes: 35 additions & 23 deletions libraries/LCD_SharpBoosterPack_SPI/LCD_SharpBoosterPack_SPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 <Energia.h>
#include "LCD_SharpBoosterPack_SPI.h"
Expand All @@ -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


Expand All @@ -68,6 +75,7 @@ unsigned char flagSendToggleVCOMCommand = 0;
#define SHARP_REQUEST_TOGGLE_VCOM 0x02



static void SendToggleVCOMCommand(void);

uint8_t textx = 0;
Expand All @@ -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;
Expand Down
10 changes: 5 additions & 5 deletions libraries/LCD_SharpBoosterPack_SPI/LCD_SharpBoosterPack_SPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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

0 comments on commit 321cb55

Please sign in to comment.