Browse Source

2021-06-23 / Eason Yang
Action :
Added : Constant CMD_ACK_VALUE_1 & CMD_ACK_VALUE_2.
Improve : check ack bytes for rx message. transceiverDgus() function.
Improve : check return result logic. lcdRegisterWrite() function.
Added : cbmp.c & cbmp.h into project.
Added : include cbmp.h.
Added : downloadBMP() & downloadBIN.

File :
1. lcmComm_dgus.h
Action 1

2. lcmComm_dgus.c
Action 2
Action 3

3. AW-CCS Project
Action 4

4. Module_LcmControl.c
Action 5
Action 6

LCM Version : V0.18

8009 3 years ago
parent
commit
04eb4f0fe9

+ 188 - 7
EVSE/Projects/AW-CCS/Apps/LCM/Module_LcmControl.c

@@ -2,7 +2,7 @@
  * Module_LcmControl.c
  *
  * Created on : 2020-10-20
- * Update on : 2021-02-20
+ * Update on : 2021-06-23
  * Author : Folus Wen, Eason Yang
  * Version : D0.01
  *
@@ -12,6 +12,7 @@
 #include	"define.h"
 #include	"main.h"
 #include 	"lcmComm_dgus.h"
+#include	"cbmp.h"
 
 //=======================================
 // Declare share memory
@@ -68,7 +69,6 @@ void setEthernetIcon();
 void setAlarmCodeAndIcon();
 void setBillingFromWebsite();
 
-
 //=======================================
 // Declare Timer
 //=======================================
@@ -116,7 +116,7 @@ uint8_t isCharging	= YES;
 //=======================================
 // Record version and date
 //=======================================
-char *FIRMWARE_UPDATE_IMAGE[3] = {"V0.17", "2021-04-28", "REV.01.00"};
+char *FIRMWARE_UPDATE_IMAGE[3] = {"V0.18", "2021-06-23", "REV.01.00"};
 
 
 //=======================================
@@ -893,7 +893,7 @@ float getPresentFinalCost(uint8_t gun_index)
 
 //=======================================
 // Setting billing ( BACKEND )
-//=======================================-
+//=======================================
 void setBillingFromBackend(uint8_t gun_index, uint8_t system_mode)
 {
 	if((system("pidof -s OcppBackend > /dev/null") != 0))
@@ -1562,8 +1562,8 @@ void setBatteryAnimation(uint8_t gun_index, uint8_t system_mode)
 			{
 				// SET BATTERY PERCENTAGE TEXT TO DISAPPEAR
 				setDisplayValue(TEXT_PERCENTAGE, DISAPPEAR);
-				
-				if(ShmCharger->gun_info[gun_index].primaryMcuState.relay_state == ON)
+
+				if((ShmCharger->gun_info[gun_index].primaryMcuState.relay_state == ON))
 				{
 					// SET BATTERY ANIMATION
 					if((BATTERY_LEVEL_STATUS == BATTERY_LEVEL_5))
@@ -1702,7 +1702,8 @@ void setConnectionAnimation(uint8_t gun_index, uint8_t system_mode)
 
 			break;
 		case SYS_MODE_CHARGING:
-			if(ShmCharger->gun_info[gun_index].primaryMcuState.relay_state == ON)
+
+			if((ShmCharger->gun_info[gun_index].primaryMcuState.relay_state == ON))
 			{
 				if((CONNECTION_LEVEL_STATUS == CONNECTION_LEVEL_0) && (DiffTimebWithNow(startTime[gun_index][TMR_IDX_CONNECTION]) > (TIME_ANIMATION_CONNECTION)))
 				{
@@ -2061,6 +2062,186 @@ int InitComPort()
 	return fd;
 }
 
+//=======================================
+// Download image
+//=======================================
+int downloadBMP(uint8_t picIdx, char *filename)
+{
+	int result = PASS;
+	BMP *bmp;
+	struct stat fileSt;
+	uint32_t pageSize = 0xf0;
+	uint32_t pixelSize;
+	uint32_t transferedByte=0;
+	uint16_t bufferRamAddr = 0x8000;
+
+	// Reset LCD
+	uint8_t cmd_reset[] = {0x55, 0xaa, 0x5a, 0xa5};
+	if(lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, 0x04, cmd_reset, ARRAY_SIZE(cmd_reset)) == FAIL)
+	{
+		DEBUG_INFO("LCD reset fail.\n");
+	}
+
+	// Get image file size
+	stat(filename, &fileSt);
+	bmp = bopen(filename);
+	uint8_t buf[bmp->width*bmp->height*2];
+
+	DEBUG_INFO("Image filename: %s\n", filename);
+	DEBUG_INFO("Image width: %d height: %d\n", bmp->width, bmp->height);
+	DEBUG_INFO("Image data size: %d\n", ARRAY_SIZE(buf));
+
+	// Get bmp pixel data and convert to 16 bit color
+	for(uint16_t idxY=0 ; idxY<bmp->height ; idxY++)
+	{
+		for(uint16_t idxX=0 ; idxX<bmp->width ; idxX++)
+		{
+			uint8_t r, g, b;
+			get_pixel_rgb(bmp, idxX, (bmp->height-idxY-1), &r, &g, &b);
+			buf[(2*((idxY*bmp->width) + idxX)) + 0] = ((((r>>3)<<11) | ((g>>2)<<5) | (b>>3)) >> 8) & 0xff;
+			buf[(2*((idxY*bmp->width) + idxX)) + 1] = ((((r>>3)<<11) | ((g>>2)<<5) | (b>>3)) >> 0) & 0xff;
+		}
+	}
+	bclose(bmp);
+
+	// Transfer pixel to screen page
+	pixelSize = ARRAY_SIZE(buf);
+	for(uint16_t idxSrcData=0;idxSrcData<(((pixelSize%pageSize)==0)?(pixelSize/pageSize):(pixelSize/pageSize)+1);idxSrcData++)
+	{
+		//DEBUG_INFO("Buffer start data address: 0x%08X\n", (idxSrcData*pageSize));
+		//DEBUG_INFO("  Image start ram address: 0x%08X\n", ((idxSrcData*pageSize) >> 1));
+		uint8_t display_cmd[] ={0x5a, (bufferRamAddr>>8)&0xff, (bufferRamAddr>>0)&0xff, 0x00, 0x00, 0x00, 0x00, 0x00};
+
+		if((idxSrcData+1) != (((pixelSize%pageSize)==0)?(pixelSize/pageSize):(pixelSize/pageSize)+1))
+		{
+			// Data transfer
+			while(lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, bufferRamAddr, &buf[(idxSrcData*pageSize)], pageSize) != PASS)
+			{
+				DEBUG_INFO("Transfer data to ram 0x%04X fail.\n", transferedByte);
+			}
+			transferedByte += pageSize;
+
+			display_cmd[3] = ((pageSize>>1) >> 8) & 0xff;							// Data length high byte
+			display_cmd[4] = ((pageSize>>1) >> 0) & 0xff;							// Data length low byte
+			display_cmd[5] = (((idxSrcData*pageSize)>>1) >> 16) & 0xff;				// Screen on ram address 1st byte
+			display_cmd[6] = (((idxSrcData*pageSize)>>1) >> 8) & 0xff;				// Screen on ram address 2nd byte
+			display_cmd[7] = (((idxSrcData*pageSize)>>1) >> 0) & 0xff;				// Screen on ram address 3th byte
+		}
+		else
+		{
+			// Last data transfer
+			while(lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, bufferRamAddr, &buf[(idxSrcData*pageSize)], (pixelSize-(idxSrcData*pageSize))) != PASS)
+			{
+				DEBUG_INFO("Transfer data to ram 0x%04X fail.\n", transferedByte);
+			}
+			transferedByte += (pixelSize-(idxSrcData*pageSize));
+
+			display_cmd[3] = (((pixelSize-(idxSrcData*pageSize))>>1) >> 8) & 0xff;	// Data length high byte
+			display_cmd[4] = (((pixelSize-(idxSrcData*pageSize))>>1) >> 0) & 0xff;	// Data length low byte
+			display_cmd[5] = (((idxSrcData*pageSize)>>1) >> 16) & 0xff;				// Screen on ram address 1st byte
+			display_cmd[6] = (((idxSrcData*pageSize)>>1) >> 8) & 0xff;				// Screen on ram address 2nd byte
+			display_cmd[7] = (((idxSrcData*pageSize)>>1) >> 0) & 0xff;				// Screen on ram address 3th byte
+		}
+
+		// Move data from ram to flash
+		while(lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, 0xa2, display_cmd, ARRAY_SIZE(display_cmd)) != PASS)
+		{
+			DEBUG_INFO("Write data to display buffer 0x%04X fail.\n", transferedByte);
+		}
+	}
+
+	// Save image to target address
+	uint8_t save_cmd[] ={0x5a, 0x02, ((picIdx>>8)&0xff), (picIdx&0xff)};
+	while(lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, 0x84, save_cmd, ARRAY_SIZE(save_cmd)) != PASS)
+	{
+		DEBUG_INFO("Save image fail.\n");
+	}
+	DEBUG_INFO("Save image success.\n");
+
+	return result;
+}
+
+//=======================================
+// Download image
+//=======================================
+int downloadBIN(uint8_t targetAddr, char *filename)
+{
+	int result = PASS;
+	int fd;
+	struct stat fileSt;
+	uint32_t pageSize = 128;
+	uint32_t blocklSize = 32768;
+	uint32_t transferedByte=0;
+	uint16_t bufferRamAddr = 0x8000;
+
+	// Reset LCD
+	uint8_t cmd_reset[] = {0x55, 0xaa, 0x5a, 0xa5};
+	if(lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, 0x04, cmd_reset, ARRAY_SIZE(cmd_reset)) == FAIL)
+	{
+		DEBUG_INFO("LCD reset fail.\n");
+	}
+
+	// Get image file size
+	stat(filename, &fileSt);
+	uint8_t buf[(fileSt.st_size%32768==0?fileSt.st_size/32768:(fileSt.st_size/32768)+1)*32768];
+
+	DEBUG_INFO("Bin filename: %s\n", filename);
+	DEBUG_INFO("Bin data size: %d\n", fileSt.st_size);
+
+	fd = open(filename, O_RDWR);
+	if (fd < 0)
+	{
+		DEBUG_WARN("Bin can not be open.\n");
+		result = FAIL;
+	}
+	else
+	{
+		for(uint8_t idxBinSrc=0;idxBinSrc<(fileSt.st_size%32768==0?fileSt.st_size/32768:(fileSt.st_size/32768)+1);idxBinSrc++)
+		{
+			// Read data from bin file
+			memset(buf, 0x00, ARRAY_SIZE(buf));
+			read(fd, buf, ARRAY_SIZE(buf));
+			close(fd);
+
+			// Transfer data to ram
+			for(uint16_t idxSrcData=0;idxSrcData<(((blocklSize%pageSize)==0)?(blocklSize/pageSize):(blocklSize/pageSize)+1);idxSrcData++)
+			{
+				//DEBUG_INFO("Buffer start data address: 0x%08X\n", (idxBinSrc*blocklSize)+(idxSrcData*pageSize));
+				//DEBUG_INFO("  Image start ram address: 0x%08X\n", ((idxSrcData*pageSize) >> 1));
+
+				if((idxSrcData+1) != (((blocklSize%pageSize)==0)?(blocklSize/pageSize):(blocklSize/pageSize)+1))
+				{
+					// Data transfer
+					while(lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, bufferRamAddr+((idxSrcData*pageSize)>>1), &buf[(idxBinSrc*blocklSize)+(idxSrcData*pageSize)], pageSize) != PASS)
+					{
+						DEBUG_INFO("Transfer data to ram 0x%04X fail.\n", transferedByte);
+					}
+					transferedByte += pageSize;
+				}
+				else
+				{
+					// Last data transfer
+					while(lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, bufferRamAddr+((idxSrcData*pageSize)>>1), &buf[(idxBinSrc*blocklSize)+(idxSrcData*pageSize)], (blocklSize-(idxSrcData*pageSize)))!= PASS)
+					{
+						DEBUG_INFO("Transfer data to ram 0x%04X fail.\n", transferedByte);
+					}
+					transferedByte += (blocklSize-(idxSrcData*pageSize));
+				}
+			}
+
+			// Move data from ram to flash
+			uint8_t save_cmd[] ={0x5a, 0x02, ((((targetAddr*8)+idxBinSrc)>>8)&0xff), ((((targetAddr*8)+idxBinSrc)>>0)&0xff), ((bufferRamAddr>>8)&0xff), ((bufferRamAddr>>0)&0xff), 0x00, 0x01, 0x00, 0x00, 0x00, 0x00};
+			while(lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, 0xaa, save_cmd, ARRAY_SIZE(save_cmd)) != PASS)
+			{
+				DEBUG_INFO("Save bin file to 0x%04X fail.\n", ((targetAddr*8)+idxBinSrc));
+			}
+			DEBUG_INFO("Save bin file on 0x%04X success.\n", ((targetAddr*8)+idxBinSrc));
+		}
+	}
+
+	return result;
+}
+
 //=======================================
 // Main process
 //=======================================

+ 315 - 0
EVSE/Projects/AW-CCS/Apps/LCM/cbmp.c

@@ -0,0 +1,315 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include "cbmp.h"
+
+// Constants
+
+#define BITS_PER_BYTE 8
+
+#define BLUE 0
+#define GREEN 1
+#define RED 2
+#define ALPHA 3
+
+#define PIXEL_ARRAY_START_BYTES 4
+#define PIXEL_ARRAY_START_OFFSET 10
+
+#define WIDTH_BYTES 4
+#define WIDTH_OFFSET 18
+
+#define HEIGHT_BYTES 4
+#define HEIGHT_OFFSET 22
+
+#define DEPTH_BYTES 2
+#define DEPTH_OFFSET 28
+
+// Private function declarations
+
+void _throw_error(char* message);
+unsigned int _get_int_from_buffer(unsigned int bytes, 
+                                  unsigned int offset, 
+                                  unsigned char* buffer);
+unsigned int _get_file_byte_number(FILE* fp);
+unsigned char* _get_file_byte_contents(FILE* fp, unsigned int file_byte_number);
+int _validate_file_type(unsigned char* file_byte_contents);
+int _validate_depth(unsigned int depth);
+unsigned int _get_pixel_array_start(unsigned char* file_byte_contents);
+int _get_width(unsigned char* file_byte_contents);
+int _get_height(unsigned char* file_byte_contents);
+unsigned int _get_depth(unsigned char* file_byte_contents);
+void _update_file_byte_contents(BMP* bmp, int index, int offset, int channel);
+void _populate_pixel_array(BMP* bmp);
+void _map(BMP* bmp, void (*f)(BMP* bmp, int, int, int));
+void _get_pixel(BMP* bmp, int index, int offset, int channel);
+
+// Public function implementations
+
+BMP* bopen(char* file_path)
+{
+    FILE* fp = fopen(file_path, "rb");
+  
+    if (fp == NULL)
+    {
+        perror("Error opening file");
+        exit(EXIT_FAILURE);
+    }
+
+    BMP* bmp = (BMP*) malloc(sizeof(BMP));
+    bmp->file_byte_number = _get_file_byte_number(fp);
+    bmp->file_byte_contents = _get_file_byte_contents(fp, bmp->file_byte_number);
+    fclose(fp);
+
+    if(!_validate_file_type(bmp->file_byte_contents))
+    {
+        _throw_error("Invalid file type");
+    }
+
+    bmp->pixel_array_start = _get_pixel_array_start(bmp->file_byte_contents);
+
+    bmp->width = _get_width(bmp->file_byte_contents);
+    bmp->height = _get_height(bmp->file_byte_contents);
+    bmp->depth = _get_depth(bmp->file_byte_contents);
+
+    if(!_validate_depth(bmp->depth))
+    {
+        _throw_error("Invalid file depth");
+    }
+
+    _populate_pixel_array(bmp);
+
+    return bmp;
+}
+
+BMP* b_deep_copy(BMP* to_copy)
+{
+    BMP* copy = (BMP*) malloc(sizeof(BMP));
+    copy->file_byte_number = to_copy->file_byte_number;
+    copy->pixel_array_start = to_copy->pixel_array_start;
+    copy->width = to_copy->width;
+    copy->height = to_copy->height;
+    copy->depth = to_copy->depth;
+
+    copy->file_byte_contents = (unsigned char*) malloc(copy->file_byte_number * sizeof(unsigned char));
+
+    unsigned int i;
+    for (i = 0; i < copy->file_byte_number; i++)
+    {
+        copy->file_byte_contents[i] = to_copy->file_byte_contents[i];
+    }
+
+    copy->pixels = (pixel*) malloc(copy->width * copy->height * sizeof(pixel));
+
+    unsigned int x, y;
+    int index;
+    for (y = 0; y < copy->height; y++)
+    {
+        for (x = 0; x < copy->width; x++)
+        {
+            index = y * copy->width + x;
+            copy->pixels[index].red = to_copy->pixels[index].red;
+            copy->pixels[index].green = to_copy->pixels[index].green;
+            copy->pixels[index].blue = to_copy->pixels[index].blue;
+            copy->pixels[index].alpha = to_copy->pixels[index].alpha;
+        }
+    }
+
+    return copy;
+}
+
+int get_width(BMP* bmp)
+{
+    return bmp->width;
+}
+
+int get_height(BMP* bmp)
+{
+    return bmp->height;
+}
+
+unsigned int get_depth(BMP* bmp)
+{
+    return bmp->depth;
+}
+
+void get_pixel_rgb(BMP* bmp, int x, int y, unsigned char* r, unsigned char* g, unsigned char* b)
+{
+    int index = y * bmp->width + x;
+    *r = bmp->pixels[index].red;
+    *g = bmp->pixels[index].green;
+    *b = bmp->pixels[index].blue;
+}
+
+void set_pixel_rgb(BMP* bmp, int x, int y, unsigned char r, unsigned char g, unsigned char b)
+{
+    int index = y * bmp->width + x;
+    bmp->pixels[index].red = r;
+    bmp->pixels[index].green = g;
+    bmp->pixels[index].blue = b;
+}
+
+void bwrite(BMP* bmp, char* file_name)
+{
+    _map(bmp, _update_file_byte_contents);
+
+    FILE* fp = fopen(file_name, "wb");
+    fwrite(bmp->file_byte_contents, sizeof(char), bmp->file_byte_number, fp);
+    fclose(fp);
+}
+
+void bclose(BMP* bmp)
+{
+    free(bmp->pixels);
+    bmp->pixels = NULL;
+    free(bmp->file_byte_contents);
+    bmp->file_byte_contents = NULL;
+    free(bmp);
+    bmp = NULL;
+}
+
+
+// Private function implementations
+
+void _throw_error(char* message)
+{
+    fprintf(stderr, "%s\n", message);
+    exit(1);
+}
+
+unsigned int _get_int_from_buffer(unsigned int bytes, 
+                                  unsigned int offset, 
+                                  unsigned char* buffer)
+{
+    unsigned char* _buffer = (unsigned char*) malloc(bytes * sizeof(unsigned char));
+
+    unsigned int i;
+    for (i = 0; i < bytes; i++)
+    {
+        _buffer[i] = buffer[i + offset];
+    }
+
+    unsigned int value = *(unsigned int*) _buffer;
+    free(_buffer);
+    return value;
+}
+
+unsigned int _get_file_byte_number(FILE* fp)
+{
+    unsigned int byte_number;
+    fseek(fp, 0, SEEK_END);
+    byte_number = ftell(fp);
+    rewind(fp);
+    return byte_number;
+}
+
+unsigned char* _get_file_byte_contents(FILE* fp, unsigned int file_byte_number)
+{
+    unsigned char* buffer = (unsigned char*) malloc(file_byte_number * sizeof(char));
+    unsigned int result = fread(buffer, 1, file_byte_number, fp);
+
+    if (result != file_byte_number)
+    {
+        _throw_error("There was a problem reading the file");
+    }
+
+
+    return buffer;
+}
+
+int _validate_file_type(unsigned char* file_byte_contents)
+{
+    return file_byte_contents[0] == 'B' && file_byte_contents[1] == 'M';
+}
+
+int _validate_depth(unsigned int depth)
+{
+    return depth == 24 || depth == 32;
+}
+
+unsigned int _get_pixel_array_start(unsigned char* file_byte_contents)
+{
+    return _get_int_from_buffer(PIXEL_ARRAY_START_BYTES, PIXEL_ARRAY_START_OFFSET, file_byte_contents);
+}
+
+int _get_width(unsigned char* file_byte_contents)
+{
+    return (int) _get_int_from_buffer(WIDTH_BYTES, WIDTH_OFFSET, file_byte_contents);
+}
+
+int _get_height(unsigned char* file_byte_contents)
+{
+    return (int) _get_int_from_buffer(HEIGHT_BYTES, HEIGHT_OFFSET, file_byte_contents);
+}
+
+unsigned int _get_depth(unsigned char* file_byte_contents)
+{
+    return _get_int_from_buffer(DEPTH_BYTES, DEPTH_OFFSET, file_byte_contents);
+}
+
+void _update_file_byte_contents(BMP* bmp, int index, int offset, int channel)
+{
+    char value;
+    switch(channel)
+    {
+        case BLUE:
+            value = bmp->pixels[index].blue;
+            break;
+        case GREEN:
+            value = bmp->pixels[index].green;
+            break;
+        case RED:
+            value = bmp->pixels[index].red;
+            break;
+        case ALPHA:
+            value = bmp->pixels[index].alpha;
+            break;
+    }
+    bmp->file_byte_contents[offset + channel] = value;
+}
+
+void _populate_pixel_array(BMP* bmp)
+{
+    bmp->pixels = (pixel*) malloc(bmp->width * bmp->height * sizeof(pixel));
+    _map(bmp, _get_pixel);
+}
+
+void _map(BMP* bmp, void (*f)(BMP*, int, int, int))
+{
+    int channels = bmp->depth / (sizeof(unsigned char) * BITS_PER_BYTE);
+    int row_size = ((int) (bmp->depth * bmp->width + 31) / 32) * 4;
+    int padding = row_size - bmp->width * channels;
+
+    int c;
+    unsigned int x, y, index, offset;
+    for (y = 0; y < bmp->height; y++)
+    {
+        for (x = 0; x < bmp->width; x++)
+        {
+            index = y * bmp->width + x;
+            offset = bmp->pixel_array_start + index * channels + y * padding;
+            for (c = 0; c < channels; c++)
+            {
+                (*f)(bmp, index, offset, c);
+            }
+        }
+    }
+}
+
+void _get_pixel(BMP* bmp, int index, int offset, int channel)
+{
+    unsigned char value = _get_int_from_buffer(sizeof(unsigned char), offset + channel, bmp->file_byte_contents);
+    switch(channel)
+    {
+        case BLUE:
+            bmp->pixels[index].blue = value;
+            break;
+        case GREEN:
+            bmp->pixels[index].green = value;
+            break;
+        case RED:
+            bmp->pixels[index].red = value;
+            break;
+        case ALPHA:
+            bmp->pixels[index].alpha = value;
+            break;
+    }
+}

+ 54 - 0
EVSE/Projects/AW-CCS/Apps/LCM/cbmp.h

@@ -0,0 +1,54 @@
+#ifndef CBMP_CBMP_H
+#define CBMP_CBMP_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// Pixel structure
+// Not meant to be edited directly
+// Please use the API
+
+typedef struct pixel_data
+{
+    unsigned char red;
+    unsigned char green;
+    unsigned char blue;
+    unsigned char alpha;
+} pixel;
+
+// BMP structure
+// Not meant to be edited directly
+// Please use the API
+
+typedef struct BMP_data
+{
+    unsigned int file_byte_number;
+    unsigned char* file_byte_contents;
+
+    unsigned int pixel_array_start;
+
+    unsigned int width;
+    unsigned int height;
+    unsigned int depth;
+
+    pixel* pixels;
+} BMP;
+
+// Public function declarations
+
+BMP* bopen(char* file_path);
+BMP* b_deep_copy(BMP* to_copy);
+int get_width(BMP* bmp);
+int get_height(BMP* bmp);
+unsigned int get_depth(BMP* bmp);
+void get_pixel_rgb(BMP* bmp, int x, int y, unsigned char* r, unsigned char* g, unsigned char* b);
+void set_pixel_rgb(BMP* bmp, int x, int y, unsigned char r, unsigned char g, unsigned char b);
+void bwrite(BMP* bmp, char* file_name);
+void bclose(BMP* bmp);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // CBMP_CBMP_H

+ 25 - 5
EVSE/Projects/AW-CCS/Apps/LCM/lcmComm_dgus.c

@@ -2,7 +2,7 @@
  * lcmComm_dgus.c
  *
  * Created on : 2020-10-20
- * Update on : 2021-02-20
+ * Update on : 2021-06-23
  * Author : Folus Wen, Eason Yang
  * Version : D0.01
  *
@@ -51,7 +51,27 @@ int transceiverDgus(int32_t fd, uint8_t *tx, uint16_t tx_len, uint8_t *rx, uint1
 	{
 		if(tx[3] == CMD_REG_WRITE_DATA)
 		{
-			result = PASS;
+			len = read(fd, rx, rx_len);
+			if(len > 0)
+			{
+				if((rx[0] == CMD_HEADER_1) && (rx[1] == CMD_HEADER_2))
+				{
+					if((rx[3] == CMD_REG_WRITE_DATA) && ((rx[4] == CMD_ACK_VALUE_1) && (rx[5] == CMD_ACK_VALUE_2)))
+					{
+						#ifdef isDebugPrint
+						displayMessageDgus(rx, len, YES);
+						#endif
+
+						result = PASS;
+					}
+					else
+					{}
+				}
+				else
+				{}
+			}
+			else
+			{}
 		}
 		else if(tx[3] == CMD_REG_READ_DATA)
 		{
@@ -62,9 +82,9 @@ int transceiverDgus(int32_t fd, uint8_t *tx, uint16_t tx_len, uint8_t *rx, uint1
 				{
 					if(rx[3] == CMD_REG_READ_DATA)
 					{
-
+						#ifdef isDebugPrint
 						displayMessageDgus(rx, len, YES);
-
+						#endif
 
 						result = PASS;
 					}
@@ -122,7 +142,7 @@ int8_t lcdRegisterWrite(int32_t fd, uint8_t regType, uint16_t address, uint8_t *
 
 	if(fd > 0)
 	{
-		if(transceiverDgus(fd, tx, ARRAY_SIZE(tx), rx, ARRAY_SIZE(rx)))
+		if(transceiverDgus(fd, tx, ARRAY_SIZE(tx), rx, ARRAY_SIZE(rx)) == PASS)
 		{
 			result = PASS;
 		}

+ 3 - 1
EVSE/Projects/AW-CCS/Apps/LCM/lcmComm_dgus.h

@@ -2,7 +2,7 @@
  * lcmComm_dwin.h
  *
  * Created on : 2020-10-20
- * Update on : 2021-02-20
+ * Update on : 2021-06-23
  * Author : Folus Wen, Eason Yang
  * Version : D0.01
  *
@@ -79,6 +79,8 @@
 #define CMD_REG_READ						0x81
 #define CMD_REG_WRITE_DATA					0x82
 #define CMD_REG_READ_DATA					0x83
+#define CMD_ACK_VALUE_1						0x4F
+#define CMD_ACK_VALUE_2						0x4B
 
 //=======================================
 // LCD system screen