Interfacing Bs2 with uoled-128-g2 screen
lwcyb
Posts: 13
Hello,
I'm attempting to interface a BS2 to a 4D uoled-128-g2 1.5" screen, and I'm running into an issue. After successfully making graphics appear on the screen using 4D's developer environment with a visi program, I've moved on to the serial environment so I can begin trying to build a serial program. I set the screen back to default serial mode by clicking the SPE Load button in the 4d developer environment. I'm trying to send the screen serial commands from the BS2 now, but I apparently I am not sending the correct bytes. I've tried a bunch of different commands in the 4D serial commands listing, but none of them are acknowledged by the module, I always get the wrong byte back (not 06). I feel like I'm missing something here, so if anyone has any tips I'd greatly appreciate them.
Here's the BS2 code I'm using to send serial commands to the uoled module:
I'm attempting to interface a BS2 to a 4D uoled-128-g2 1.5" screen, and I'm running into an issue. After successfully making graphics appear on the screen using 4D's developer environment with a visi program, I've moved on to the serial environment so I can begin trying to build a serial program. I set the screen back to default serial mode by clicking the SPE Load button in the 4d developer environment. I'm trying to send the screen serial commands from the BS2 now, but I apparently I am not sending the correct bytes. I've tried a bunch of different commands in the 4D serial commands listing, but none of them are acknowledged by the module, I always get the wrong byte back (not 06). I feel like I'm missing something here, so if anyone has any tips I'd greatly appreciate them.
Here's the BS2 code I'm using to send serial commands to the uoled module:
PAUSE 2000 SEROUT opin, baud, [$55] GOSUB GetACK PAUSE 100 GetACK: SERIN ipin, baud, [Rx] IF (Rx = $06) THEN DEBUG "test" RETURN ELSE DEBUG "NAK ", HEX Rx, CR ENDIF RETURN
Comments
http://www.4dsystems.com.au/downloads/Software/4D-Workshop4-IDE/Docs/Serial/GOLDELOX-SPE-COMMAND-SET-REV1.3.pdf
I looked over the documentation like you suggested and I don't think $55 is an actual command for the uoled 128. I went into the 4D workshop environment and played around a little with the serial commander tool, which made me realize I wasn't sending complete commands to the screen. Comparing the documentation to the serial commander tool made me realize I was incorrectly reading the documentation - I was missing half of what was needed to be sent to the screen. I was sending the appropriate parameters but I wasn't designating what function of the goldelox "library" the screen was supposed to be accessing. No wonder it wasn't acknowledging my requests
I believe the screen is enabled to 9600 by default, so on a BS2 you should change the baud variable to 84 for the 9600 baud setting. If you've downloaded the 4D environment you can change the baud speed for the device by going to File > Options > Serial.
The code should draw two rectangles on the screen, one red, one green.
Data sheet again: http://www.4dsystems.com.au/downloads/Software/4D-Workshop4-IDE/Docs/Serial/GOLDELOX-SPE-COMMAND-SET-REV1.3.pdf