andygock / glcd

Graphic LCD Library for microcontrollers based embedded systems. Compatible with chipsets PCD854, ST7565R, NTD75451 and many AVR, LPC, PIC, STM32 devices.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Selected bounding box size issue.

des5000 opened this issue · comments

Hello Andy & all,
I have been unsuccessful in my attempts to use your LCD library.
In my application code, a function call to, for example, glcd_test_hello_world() would subsequently call glcd_update_bbox() with 0,0,127,63 xmin, ymin, xmax, ymax arguments.
glcd_bbox_selected contained possibly suspicious bounding box x/y values:
glcd_bbox_selected->x_min: 0
glcd_bbox_selected->y_min: 128
glcd_bbox_selected->x_max: 0
glcd_bbox_selected->y_max: 16

Updating the bounding box size, at glcd-0.5.2/src/glcd.c line 91:
if (xmax > glcd_bbox_selected->x_max) {
glcd_bbox_selected->x_max = xmax;
}
appears to alter glcd_bbox_selected->x_max from 0 to 127, causing a HardFault_Handler() while(1)-loop function call in the auto-generated LPC11U6x Microcontroller Startup code. This behaviour is consistent.

A further query, is the number of banks a reference to the number of display data RAM pages. Should it be #define GLCD_NUMBER_OF_BANKS (GLCD_LCD_HEIGHT / 8)? However, it didn't resolve the bounding box size issue that I appear to be experiencing.
/*

  • GLCD_NUMBER_OF_BANKS is typically GLCD_LCD_HEIGHT/8
  • Don't adjust these below unless required.
    */
    #define GLCD_NUMBER_OF_BANKS (GLCD_LCD_WIDTH / 8)
    #define GLCD_NUMBER_OF_COLS GLCD_LCD_WIDTH

Note that I am able to access the LCD module from the MCU (LPC11U68) using SPI initialisation and display data RAM commands.
Has anyone experienced similar bounding box size behaviour when developing / debugging their application? It appears that glcd_bbox_selected ymin & xmax values may have been swapped, can someone indicate where in the code these values are assigned?

Regards,
Des.

The following is a brief background to my development setup:

IDE environment: LPCXpresso v8.1.4 [Build 606] [2016-03-14]
Development board: NXP Xpresso LPC11U68 v2 Issue B
Development hardware library: LPCOpen v2.06 software package for NXP Xpresso LPC11U68 board
Graphic LCD library: glcd-0.5.2
Graphic LCD module: NHD-C12864A1Z-FS(RGB)-FBW-HT1 (ST7565P controller)

Using the following compiler-related symbols:
GLCD_CONTROLLER_ST7565R
GLCD_DEVICE_LPC11UXX
GLCD_INIT_NHD_C12864A1Z_FSW_FBW_HTT
GLCD_USE_SPI

For successful compilation, amendments to glcd-0.5.2\devices\LPC11Uxx.h, from line 50 were need for alignment with LPCXpresso SSP port and GPIO port and pin assignments:
/* Define port and pins used to connect to LCD */
#define CONTROLLER_SPI_PORT_NUMBER LPC_SSP0
#define CONTROLLER_MOSI_PORT 0
#define CONTROLLER_MOSI_PIN 9
#define CONTROLLER_MISO_PORT 0
#define CONTROLLER_MISO_PIN 8
#define CONTROLLER_SCK_PORT 1
#define CONTROLLER_SCK_PIN 29
#define CONTROLLER_SS_PORT 0
#define CONTROLLER_SS_PIN 2
#define CONTROLLER_A0_PORT 0
#define CONTROLLER_A0_PIN 12
#define CONTROLLER_RST_PORT 0
#define CONTROLLER_RST_PIN 14

/* Preprocessor macros */
#define GLCD_SELECT()     Chip_GPIO_SetPinState(LPC_GPIO, CONTROLLER_SS_PORT, CONTROLLER_SS_PIN, false)
#define GLCD_DESELECT()   Chip_GPIO_SetPinState(LPC_GPIO, CONTROLLER_SS_PORT, CONTROLLER_SS_PIN, true)
#define GLCD_A0_LOW()     Chip_GPIO_SetPinState(LPC_GPIO, CONTROLLER_A0_PORT, CONTROLLER_A0_PIN, false)
#define GLCD_A0_HIGH()    Chip_GPIO_SetPinState(LPC_GPIO, CONTROLLER_A0_PORT, CONTROLLER_A0_PIN, true)
#define GLCD_RESET_LOW()  Chip_GPIO_SetPinState(LPC_GPIO, CONTROLLER_RST_PORT, CONTROLLER_RST_PIN, false)
#define GLCD_RESET_HIGH() Chip_GPIO_SetPinState(LPC_GPIO, CONTROLLER_RST_PORT, CONTROLLER_RST_PIN, true)

For successful compilation, amendments to glcd-0.5.2\devices\LPC11Uxx.c, from line 142, using LPCOpen function call Chip_SSP_SendFrame() :
void glcd_spi_write(uint8_t c)
{
GLCD_SELECT();
//SSP_Send(CONTROLLER_SPI_PORT_NUMBER,&c,1);
Chip_SSP_SendFrame(CONTROLLER_SPI_PORT_NUMBER, c);
GLCD_DESELECT();
}

Issue resolved in v0.5.2
included adding glcd_ST7565R_init() added to glcd_init() function call