Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Bugfix: writeBitmap always writing to upper left corner.

Note: lcd->contrast(new_contrast_value) does not cause any screen response.
This may be a hardware issue with the MDFly board (with which I am testing), since the SPI command sequence seems to match the PCD8544 datasheet specs.
  • Loading branch information...
commit c49a52ed43727e24bfa42c5bc92147fc2fcf2194 1 parent 9a85dbf
@AretCarlsen authored
Showing with 18 additions and 26 deletions.
  1. +8 −2 Philips_PCD8544.cpp
  2. +10 −24 Philips_PCD8544_Server.hpp
View
10 Philips_PCD8544.cpp
@@ -46,6 +46,8 @@ template<typename SPI_bus_t, typename LCD_DC_pin_t, typename LCD_CE_pin_t, typen
* Return value : None.
*/
template<typename SPI_bus_t, typename LCD_DC_pin_t, typename LCD_CE_pin_t, typename LCD_RST_pin_t, int X_RES, int Y_RES> void Philips_PCD8544<SPI_bus_t, LCD_DC_pin_t, LCD_CE_pin_t, LCD_RST_pin_t, X_RES, Y_RES>::contrast ( byte contrast ) {
+ DEBUGprint_FORCE("L.C:%d;", contrast);
+
/* LCD Extended Commands. */
send( 0x21, LCD_CMD );
@@ -484,8 +486,10 @@ template<typename SPI_bus_t, typename LCD_DC_pin_t, typename LCD_CE_pin_t, typen
// Sanity check
if(size > CACHE_SIZE) size = CACHE_SIZE;
- /* Initialize screenCache index to 0 */
- memcpy(screenCache,imageData,size);
+ DEBUGprint_FORCE("Wbp:%d/%d;", offset, size);
+
+ // Write bitmap to cache.
+ memcpy(screenCache + offset,imageData,size);
/* Expand watermark pointers, if necessary. */
setMinimumWaterMarks(offset, offset + size - 1);
@@ -522,6 +526,8 @@ template<typename SPI_bus_t, typename LCD_DC_pin_t, typename LCD_CE_pin_t, typen
if ( HiWaterMark >= CACHE_SIZE )
HiWaterMark = CACHE_SIZE - 1;
+ DEBUGprint_FORCE("Lu:%d/%d;", LoWaterMark, HiWaterMark);
+
/* Set base address according to LoWaterMark. */
send( 0x80 | ( LoWaterMark % X_RES ), LCD_CMD );
send( 0x40 | ( LoWaterMark / X_RES ), LCD_CMD );
View
34 Philips_PCD8544_Server.hpp
@@ -6,9 +6,11 @@
#include "Philips_PCD8544.hpp"
#include <Upacket/Servers/SimpleServer.hpp>
+/*
#ifndef DEBUGprint_MISC
#define DEBUGprint_MISC(...)
#endif
+*/
namespace Philips_PCD8544{
@@ -80,26 +82,29 @@ Status::Status_t process(){
// Packet to process?
if(! packetPending()) return Status::Status__Good;
- DEBUGprint_MISC("BmS: Prc pk\n");
-
// Data in packet?
MAP::Data_t *data_ptr = offsetPacket.packet->get_data(offsetPacket.headerOffset);
if(data_ptr == NULL) return finishedWithPacket();
+ DEBUGprint_FORCE("BmS:Oc%d;", *data_ptr);
+
// Command 0: Clear screen
switch(*data_ptr){
// Clear screen
case Command__ClearScreen:
lcd->clear();
+ lcd->update();
break;
// Write bitmap
case Command__WriteBitmap: {
+ data_ptr++;
// First byte is offset. Remaining data is actual image data.
// Assumes no more than 254 bitmap bytes per packet.
uint8_t packet_size = offsetPacket.packet->back() - data_ptr;
- // Only proceed if at least one byte is to be written.
+ // Only proceed if at least one byte is to be written. (Data starts at next byte.)
if(packet_size <= 1) break;
lcd->writeBitmap(data_ptr + 1, *data_ptr, packet_size - 1);
+ lcd->update();
break;
}
// Read bitmap
@@ -108,9 +113,11 @@ Status::Status_t process(){
// Set contrast
case Command__SetContrast: {
// First byte is new contrast.
+ data_ptr++;
uint8_t packet_size = offsetPacket.packet->back() - data_ptr;
if(packet_size > 0)
lcd->contrast(*data_ptr);
+ lcd->update();
break;
}
// Write string
@@ -120,27 +127,6 @@ Status::Status_t process(){
// default:
}
- // Write packet contents out to screen, beginning at first row and performing a linefeed
- // when the right edge of the screen is encountered.
- for(uint8_t Y = 1; Y <= LCD_t::MAX_Y_FONT; Y++){
- // Start at leftmost edge of screen
- lcd->gotoXYFont(1,Y);
- while(data_ptr < offsetPacket.packet->back()){
- uint8_t response = lcd->chr(FONT_1X, *data_ptr);
- if(response != OK){
- // If wrapped, the character has actually been written.
- if(response == OK_WITH_WRAP) data_ptr++;
- // Move to next line
- break;
- }
- // Move to next character
- data_ptr++;
- }
- }
-
- // Update screen
- lcd->update();
-
return finishedWithPacket();
}
};
Please sign in to comment.
Something went wrong with that request. Please try again.