Jump to content

RS485 CDU Display Font Issue


TulsA-10

Recommended Posts

Hello people!

 

 

I have an issue getting my 3.5 tft to display the correct font over rs485. I have a correctly wired rs485 network using max487 chips as displayed by Hans and many others.

 

 

All libraries and dcs bios are fully updated.

 

 

 

The font has been corrected for the A10 via the glcdfont file under adafruit_GFX_Library.

 

 

 

 

 

 

 

Please also note that the font and cdu work perfectly via serial using the following sketch.

 

 

 

 

 

 

/*

Tell DCS-BIOS to use a serial connection and use the default Arduino Serial

library. This will work on the vast majority of Arduino-compatible boards,

but you can get corrupted data if you have too many or too slow outputs

(e.g. when you have multiple character displays), because the receive

buffer can fill up if the sketch spends too much time updating them.

 

If you can, use the IRQ Serial connection instead.

*/

#define DCSBIOS_IRQ_SERIAL

#include "DcsBios.h"

#include <Adafruit_GFX.h>

#include <UTFTGLUE.h>

 

DcsBios::Switch2Pos cduLsk3l("CDU_LSK_3L", A0);

DcsBios::Switch2Pos cduLsk5l("CDU_LSK_5L", A1);

DcsBios::Switch2Pos cduLsk7l("CDU_LSK_7L", A2);

DcsBios::Switch2Pos cduLsk9l("CDU_LSK_9L", A3);

DcsBios::Switch2Pos cduLsk3r("CDU_LSK_3R", A4);

DcsBios::Switch2Pos cduLsk5r("CDU_LSK_5R", A5);

DcsBios::Switch2Pos cduLsk7r("CDU_LSK_7R", A6);

DcsBios::Switch2Pos cduLsk9r("CDU_LSK_9R", A7);

DcsBios::Switch2Pos cduSys("CDU_SYS", A8);

DcsBios::Switch2Pos cduNav("CDU_NAV", A9);

DcsBios::Switch2Pos cduWp("CDU_WP", A10);

DcsBios::Switch2Pos cduOset("CDU_OSET", A11);

DcsBios::Switch2Pos cduFpm("CDU_FPM", A12);

DcsBios::Switch2Pos cduPrev("CDU_PREV", A13);

DcsBios::Switch2Pos cdu0("CDU_0", A14);

DcsBios::Switch2Pos cdu1("CDU_1", A15);

DcsBios::Switch2Pos cdu2("CDU_2", 2);

DcsBios::Switch2Pos cdu3("CDU_3", 3);

DcsBios::Switch2Pos cdu4("CDU_4", 4);

DcsBios::Switch2Pos cdu5("CDU_5", 5);

DcsBios::Switch2Pos cdu6("CDU_6", 6);

DcsBios::Switch2Pos cdu7("CDU_7", 7);

DcsBios::Switch2Pos cdu8("CDU_8", 8);

DcsBios::Switch2Pos cdu9("CDU_9", 9);

DcsBios::Switch3Pos cduPg("CDU_PG", 10, 11);

DcsBios::Switch3Pos cduData("CDU_DATA", 12, 13);

 

int i = 0; // just for testing/debugging

int j = 0; // just for testing/debugging

 

UTFTGLUE myGLCD(0x9486,A2,A1,A3,A4,A0);

 

// set different brightness

// bright1 = 0x01E0; // darkest

// bright2 = 0x02E0; // values just for reference

// bright3 = 0x03E0; // so you know what my intention is

// bright4 = 0x04E0;

// bright5 = 0x05E0;

// bright6 = 0x06E0;

// bright7 = 0x07E0; //brightest

int cduBrt = 0x07E0; // start value

void onCduBrtChange(unsigned int newValue) { // newValue range 0 (left/down),1 (neutral),2 (right/up)

if (newValue == 0){ // DIM/BRT-Rocker left

cduBrt = cduBrt - 0x0100;

};

if (newValue == 2){ // DIM/BRT-Rocker right

cduBrt = cduBrt + 0x0100;

};

if (cduBrt > 0x07E0){

cduBrt = 0x07E0;

};

if (cduBrt < 0x01E0){

cduBrt = 0x01E0;

};

};

DcsBios::IntegerBuffer cduBrtBuffer(0x10fa, 0x0003, 0, onCduBrtChange);

// problem: just altered lines are drawn with new brightness

 

void printChar(int row, int col, unsigned char c) {

int16_t x = 13 + col * 19;

int16_t y = row * 32 + 6;

myGLCD.drawChar(x, y, c, cduBrt, 0x0, 3); //0x07E0

}

 

/* paste code snippets from the reference documentation here */

void onCduLine0Change(char* newValue) {

for(int i = 0; i < 24; i++){

printChar(0, i, newValue);

}

}

DcsBios::StringBuffer<24> cduLine0Buffer(0x11c0, onCduLine0Change);

 

void onCduLine1Change(char* newValue) {

for(int i = 0; i < 24; i++){

printChar(1, i, newValue);

}

}

DcsBios::StringBuffer<24> cduLine1Buffer(0x11d8, onCduLine1Change);

 

void onCduLine2Change(char* newValue) {

for(int i = 0; i < 24; i++){

printChar(2, i, newValue);

}

}

DcsBios::StringBuffer<24> cduLine2Buffer(0x11f0, onCduLine2Change);

 

void onCduLine3Change(char* newValue) {

for(int i = 0; i < 24; i++){

printChar(3, i, newValue);

}

}

DcsBios::StringBuffer<24> cduLine3Buffer(0x1208, onCduLine3Change);

 

void onCduLine4Change(char* newValue) {

for(int i = 0; i < 24; i++){

printChar(4, i, newValue);

}

}

DcsBios::StringBuffer<24> cduLine4Buffer(0x1220, onCduLine4Change);

 

void onCduLine5Change(char* newValue) {

for(int i = 0; i < 24; i++){

printChar(5, i, newValue);

}

}

DcsBios::StringBuffer<24> cduLine5Buffer(0x1238, onCduLine5Change);

 

void onCduLine6Change(char* newValue) {

for(int i = 0; i < 24; i++){

printChar(6, i, newValue);

}

}

DcsBios::StringBuffer<24> cduLine6Buffer(0x1250, onCduLine6Change);

 

void onCduLine7Change(char* newValue) {

for(int i = 0; i < 24; i++){

printChar(7, i, newValue);

}

}

DcsBios::StringBuffer<24> cduLine7Buffer(0x1268, onCduLine7Change);

 

void onCduLine8Change(char* newValue) {

for(int i = 0; i < 24; i++){

printChar(8, i, newValue);

}

}

DcsBios::StringBuffer<24> cduLine8Buffer(0x1280, onCduLine8Change);

 

void onCduLine9Change(char* newValue) {

for(int i = 0; i < 24; i++){

printChar(9, i, newValue);

}

}

DcsBios::StringBuffer<24> cduLine9Buffer(0x1298, onCduLine9Change);

 

void setup() {

DcsBios::setup();

 

// Setup the LCD

myGLCD.InitLCD();

myGLCD.clrScr();

myGLCD.setTextSize(3);

myGLCD.setColor(0, 0, 0); // seems to have no effect

myGLCD.drawRect(0, 0, 0, 255);

}

 

void loop() {

DcsBios::loop();

myGLCD.invertDisplay(1);

}

 

 

 

 

 

 

 

 

 

 

So I then converted the same sketch to RS485 and uploaded it to the cdu mega slave 1.

 

 

 

 

 

 

 

 

 

/*

The following #define tells DCS-BIOS that this is a RS-485 slave device.

It also sets the address of this slave device. The slave address should be

between 1 and 126 and must be unique among all devices on the same bus.

*/

#define DCSBIOS_RS485_SLAVE 1

 

/*

The Arduino pin that is connected to the

/RE and DE pins on the RS-485 transceiver.

*/

#define TXENABLE_PIN 2

 

#include "DcsBios.h"

#include <Adafruit_GFX.h>

#include <UTFTGLUE.h>

 

/* paste code snippets from the reference documentation here */

 

DcsBios::Switch2Pos cduLsk3l("CDU_LSK_3L", A0);

DcsBios::Switch2Pos cduLsk5l("CDU_LSK_5L", A1);

DcsBios::Switch2Pos cduLsk7l("CDU_LSK_7L", A2);

DcsBios::Switch2Pos cduLsk9l("CDU_LSK_9L", A3);

DcsBios::Switch2Pos cduLsk3r("CDU_LSK_3R", A4);

DcsBios::Switch2Pos cduLsk5r("CDU_LSK_5R", A5);

DcsBios::Switch2Pos cduLsk7r("CDU_LSK_7R", A6);

DcsBios::Switch2Pos cduLsk9r("CDU_LSK_9R", A7);

DcsBios::Switch2Pos cduSys("CDU_SYS", A8);

DcsBios::Switch2Pos cduNav("CDU_NAV", A9);

DcsBios::Switch2Pos cduWp("CDU_WP", A10);

DcsBios::Switch2Pos cduOset("CDU_OSET", A11);

DcsBios::Switch2Pos cduFpm("CDU_FPM", A12);

DcsBios::Switch2Pos cduPrev("CDU_PREV", A13);

DcsBios::Switch2Pos cdu0("CDU_0", A14);

DcsBios::Switch2Pos cdu1("CDU_1", A15);

DcsBios::Switch2Pos cdu2("CDU_2", 3);

DcsBios::Switch2Pos cdu3("CDU_3", 4);

DcsBios::Switch2Pos cdu4("CDU_4", 5);

DcsBios::Switch2Pos cdu5("CDU_5", 6);

DcsBios::Switch2Pos cdu6("CDU_6", 7);

DcsBios::Switch2Pos cdu7("CDU_7", 8);

DcsBios::Switch2Pos cdu8("CDU_8", 9);

DcsBios::Switch2Pos cdu9("CDU_9", 10);

DcsBios::Switch3Pos cduPg("CDU_PG", 11, 12);

 

 

int i = 0; // just for testing/debugging

int j = 0; // just for testing/debugging

 

UTFTGLUE myGLCD(0x9486,A2,A1,A3,A4,A0);

 

// set different brightness

// bright1 = 0x01E0; // darkest

// bright2 = 0x02E0; // values just for reference

// bright3 = 0x03E0; // so you know what my intention is

// bright4 = 0x04E0;

// bright5 = 0x05E0;

// bright6 = 0x06E0;

// bright7 = 0x07E0; //brightest

int cduBrt = 0x07E0; // start value

void onCduBrtChange(unsigned int newValue) { // newValue range 0 (left/down),1 (neutral),2 (right/up)

if (newValue == 0){ // DIM/BRT-Rocker left

cduBrt = cduBrt - 0x0100;

};

if (newValue == 2){ // DIM/BRT-Rocker right

cduBrt = cduBrt + 0x0100;

};

if (cduBrt > 0x07E0){

cduBrt = 0x07E0;

};

if (cduBrt < 0x01E0){

cduBrt = 0x01E0;

};

};

DcsBios::IntegerBuffer cduBrtBuffer(0x10fa, 0x0003, 0, onCduBrtChange);

// problem: just altered lines are drawn with new brightness

 

void printChar(int row, int col, unsigned char c) {

int16_t x = 13 + col * 19;

int16_t y = row * 32 + 6;

myGLCD.drawChar(x, y, c, cduBrt, 0x0, 3); //0x07E0

}

 

/* paste code snippets from the reference documentation here */

void onCduLine0Change(char* newValue) {

for(int i = 0; i < 24; i++){

printChar(0, i, newValue);

}

}

DcsBios::StringBuffer<24> cduLine0Buffer(0x11c0, onCduLine0Change);

 

void onCduLine1Change(char* newValue) {

for(int i = 0; i < 24; i++){

printChar(1, i, newValue);

}

}

DcsBios::StringBuffer<24> cduLine1Buffer(0x11d8, onCduLine1Change);

 

void onCduLine2Change(char* newValue) {

for(int i = 0; i < 24; i++){

printChar(2, i, newValue);

}

}

DcsBios::StringBuffer<24> cduLine2Buffer(0x11f0, onCduLine2Change);

 

void onCduLine3Change(char* newValue) {

for(int i = 0; i < 24; i++){

printChar(3, i, newValue);

}

}

DcsBios::StringBuffer<24> cduLine3Buffer(0x1208, onCduLine3Change);

 

void onCduLine4Change(char* newValue) {

for(int i = 0; i < 24; i++){

printChar(4, i, newValue);

}

}

DcsBios::StringBuffer<24> cduLine4Buffer(0x1220, onCduLine4Change);

 

void onCduLine5Change(char* newValue) {

for(int i = 0; i < 24; i++){

printChar(5, i, newValue);

}

}

DcsBios::StringBuffer<24> cduLine5Buffer(0x1238, onCduLine5Change);

 

void onCduLine6Change(char* newValue) {

for(int i = 0; i < 24; i++){

printChar(6, i, newValue);

}

}

DcsBios::StringBuffer<24> cduLine6Buffer(0x1250, onCduLine6Change);

 

void onCduLine7Change(char* newValue) {

for(int i = 0; i < 24; i++){

printChar(7, i, newValue);

}

}

DcsBios::StringBuffer<24> cduLine7Buffer(0x1268, onCduLine7Change);

 

void onCduLine8Change(char* newValue) {

for(int i = 0; i < 24; i++){

printChar(8, i, newValue);

}

}

DcsBios::StringBuffer<24> cduLine8Buffer(0x1280, onCduLine8Change);

 

void onCduLine9Change(char* newValue) {

for(int i = 0; i < 24; i++){

printChar(9, i, newValue);

}

}

DcsBios::StringBuffer<24> cduLine9Buffer(0x1298, onCduLine9Change);

 

void setup() {

DcsBios::setup();

 

// Setup the LCD

myGLCD.InitLCD();

myGLCD.clrScr();

myGLCD.setTextSize(3);

myGLCD.setColor(0, 0, 0); // seems to have no effect

myGLCD.drawRect(0, 0, 0, 255);

}

 

void loop() {

DcsBios::loop();

myGLCD.invertDisplay(1);

}

 

 

 

 

 

 

Like I said, the font doesn't display correctly at all, as if I didn't update the library glcdfont.c font. It's as if the RS485 network doesn't even look at the font in the library. Weird problem, thank you for any help.

glcdfont.c.txt


Edited by TulsA-10

" I'm gonna have to be taking your car today. See I have some top secret clown business that supersedes any plans that you might have for this here vehicle."

Link to comment
Share on other sites

+++++UPDATE+++++

 

 

 

 

I got a little closer to getting this working via RS485.

 

 

I used the following sketch to get the font to display correctly for about 10 seconds but then the cdu display starts to display odd characters and won't stop.

 

 

 

 

 

#define DCSBIOS_RS485_SLAVE 1

#define TXENABLE_PIN 2

#include "DcsBios.h"

#include <Adafruit_GFX.h>

#include <UTFTGLUE.h>

 

DcsBios::Switch2Pos cduLsk3l("CDU_LSK_3L", A0);

DcsBios::Switch2Pos cduLsk5l("CDU_LSK_5L", A1);

DcsBios::Switch2Pos cduLsk7l("CDU_LSK_7L", A2);

DcsBios::Switch2Pos cduLsk9l("CDU_LSK_9L", A3);

DcsBios::Switch2Pos cduLsk3r("CDU_LSK_3R", A4);

DcsBios::Switch2Pos cduLsk5r("CDU_LSK_5R", A5);

DcsBios::Switch2Pos cduLsk7r("CDU_LSK_7R", A6);

DcsBios::Switch2Pos cduLsk9r("CDU_LSK_9R", A7);

DcsBios::Switch2Pos cduSys("CDU_SYS", A8);

DcsBios::Switch2Pos cduNav("CDU_NAV", A9);

DcsBios::Switch2Pos cduWp("CDU_WP", A10);

DcsBios::Switch2Pos cduOset("CDU_OSET", A11);

DcsBios::Switch2Pos cduFpm("CDU_FPM", A12);

DcsBios::Switch2Pos cduPrev("CDU_PREV", A13);

DcsBios::Switch2Pos cdu0("CDU_0", A14);

DcsBios::Switch2Pos cdu1("CDU_1", A15);

DcsBios::Switch2Pos cdu2("CDU_2", 3);

DcsBios::Switch2Pos cdu3("CDU_3", 4);

DcsBios::Switch2Pos cdu4("CDU_4", 5);

DcsBios::Switch2Pos cdu5("CDU_5", 6);

DcsBios::Switch2Pos cdu6("CDU_6", 7);

DcsBios::Switch2Pos cdu7("CDU_7", 8);

DcsBios::Switch2Pos cdu8("CDU_8", 9);

DcsBios::Switch2Pos cdu9("CDU_9", 10);

DcsBios::Switch3Pos cduPg("CDU_PG", 11, 12);

 

 

UTFTGLUE myGLCD(0x9486,A2,A1,A3,A4,A0);

 

void printChar(int row, int col, unsigned char c) {

int16_t x = 13 + col * 19;

int16_t y = row * 32 + 6;

myGLCD.drawChar(x, y, c, 0x07E0, 0x0, 3);

}

 

/* paste code snippets from the reference documentation here */

void onCduLine0Change(char* newValue) {

for(int i = 0; i < 24; i++){

printChar(0, i, newValue);

}

}

DcsBios::StringBuffer<24> cduLine0Buffer(0x11c0, onCduLine0Change);

 

void onCduLine1Change(char* newValue) {

for(int i = 0; i < 24; i++){

printChar(1, i, newValue);

}

}

DcsBios::StringBuffer<24> cduLine1Buffer(0x11d8, onCduLine1Change);

 

void onCduLine2Change(char* newValue) {

for(int i = 0; i < 24; i++){

printChar(2, i, newValue);

}

}

DcsBios::StringBuffer<24> cduLine2Buffer(0x11f0, onCduLine2Change);

 

void onCduLine3Change(char* newValue) {

for(int i = 0; i < 24; i++){

printChar(3, i, newValue);

}

}

DcsBios::StringBuffer<24> cduLine3Buffer(0x1208, onCduLine3Change);

 

void onCduLine4Change(char* newValue) {

for(int i = 0; i < 24; i++){

printChar(4, i, newValue);

}

}

DcsBios::StringBuffer<24> cduLine4Buffer(0x1220, onCduLine4Change);

 

void onCduLine5Change(char* newValue) {

for(int i = 0; i < 24; i++){

printChar(5, i, newValue);

}

}

DcsBios::StringBuffer<24> cduLine5Buffer(0x1238, onCduLine5Change);

 

void onCduLine6Change(char* newValue) {

for(int i = 0; i < 24; i++){

printChar(6, i, newValue);

}

}

DcsBios::StringBuffer<24> cduLine6Buffer(0x1250, onCduLine6Change);

 

void onCduLine7Change(char* newValue) {

for(int i = 0; i < 24; i++){

printChar(7, i, newValue);

}

}

DcsBios::StringBuffer<24> cduLine7Buffer(0x1268, onCduLine7Change);

 

void onCduLine8Change(char* newValue) {

for(int i = 0; i < 24; i++){

printChar(8, i, newValue);

}

}

DcsBios::StringBuffer<24> cduLine8Buffer(0x1280, onCduLine8Change);

 

void onCduLine9Change(char* newValue) {

for(int i = 0; i < 24; i++){

printChar(9, i, newValue);

}

}

DcsBios::StringBuffer<24> cduLine9Buffer(0x1298, onCduLine9Change);

 

void setup() {

DcsBios::setup();

 

// Setup the LCD

myGLCD.InitLCD();

myGLCD.clrScr();

myGLCD.setTextSize(3);

myGLCD.setColor(0, 0, 0); // seems to have no effect

myGLCD.drawRect(0, 0, 0, 255); //change to these settings for A10 font

myGLCD.invertDisplay(1);

}

 

void loop() {

DcsBios::loop();

}


Edited by TulsA-10

" I'm gonna have to be taking your car today. See I have some top secret clown business that supersedes any plans that you might have for this here vehicle."

Link to comment
Share on other sites

  • 3 weeks later...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...