I have recently bought a nice vintage display called the HDSP-2203. The HDSP-2203 is able to display eight ASCII characters. This display has similar interface and commands as the HDSP-2112HDSP-2112. I have decided to connect it to to the "Blue Pill" board which has an STM32 MCU. Connection was made with usage a universal PCB to which was the display soldered. List of mappings of display pins to board pins is present in source code. Display has parallel interface and driving it is really simple. We have control commands which allow to change brightness and to display given character.
The code was written in Arduino IDE. In setup part we need to initialize the display and serial.
Additionally the RTC library is used. In main loop firstly we checking if we received a new timestamp via serial . If it is available then RTC is configured based on it. After that there is checking if we should update display with new value of hour, minute and second. Below there is source code:
#include <RTClock.h> RTClock rt (RTCSEL_HSE); static const uint8_t RST = PA15; static const uint8_t FL = PB3; static const uint8_t A_0 = PB4; static const uint8_t A_1 = PB5; static const uint8_t A_2 = PB6; static const uint8_t A_3 = PB7; static const uint8_t A_4 = PA0; static const uint8_t WR = PC15; static const uint8_t D_0 = PB8; static const uint8_t D_1 = PC14; static const uint8_t D_2 = PA1; static const uint8_t D_3 = PA2; static const uint8_t D_4 = PA3; static const uint8_t D_5 = PA4; static const uint8_t D_6 = PA5; static const uint8_t D_7 = PA7; void initDisplay(void) { pinMode(RST, OUTPUT); pinMode(FL, OUTPUT); pinMode(A_0, OUTPUT); pinMode(A_1, OUTPUT); pinMode(A_2, OUTPUT); pinMode(A_3, OUTPUT); pinMode(A_4, OUTPUT); pinMode(WR, OUTPUT); pinMode(D_0, OUTPUT); pinMode(D_1, OUTPUT); pinMode(D_2, OUTPUT); pinMode(D_3, OUTPUT); pinMode(D_4, OUTPUT); pinMode(D_5, OUTPUT); pinMode(D_6, OUTPUT); pinMode(D_7, OUTPUT); digitalWrite(WR, HIGH); digitalWrite(RST, LOW); delay(10); digitalWrite(RST, HIGH); digitalWrite(FL, HIGH); delay(50); } void writeCharacter(char character, uint8_t displayNumber) { digitalWrite(A_4, HIGH); digitalWrite(A_3, HIGH); digitalWrite(A_2, (displayNumber & 0x04)); digitalWrite(A_1, (displayNumber & 0x02)); digitalWrite(A_0, (displayNumber & 0x01)); digitalWrite(D_7, LOW); digitalWrite(D_6, (character & 0x40)); digitalWrite(D_5, (character & 0x20)); digitalWrite(D_4, (character & 0x10)); digitalWrite(D_3, (character & 0x08)); digitalWrite(D_2, (character & 0x04)); digitalWrite(D_1, (character & 0x02)); digitalWrite(D_0, (character & 0x01)); digitalWrite(WR, LOW); delayMicroseconds(140); digitalWrite(WR, HIGH); } void setBrightness(uint8_t level) { digitalWrite(A_4, HIGH); digitalWrite(A_3, LOW); digitalWrite(A_2, LOW); digitalWrite(A_1, LOW); digitalWrite(D_7, LOW); digitalWrite(D_6, LOW); digitalWrite(D_5, LOW); digitalWrite(D_4, LOW); digitalWrite(D_3, LOW); digitalWrite(D_2, (level & 0x04)); digitalWrite(D_1, (level & 0x02)); digitalWrite(D_0, (level & 0x01)); digitalWrite(WR, LOW); delayMicroseconds(140); digitalWrite(WR, HIGH); } void clearDisplay(void) { for (uint8_t displayNumber = 0; displayNumber < 7; displayNumber++) { writeCharacter(' ', displayNumber); } } void setup() { // put your setup code here, to run once: initDisplay(); clearDisplay(); setBrightness(6); Serial.begin(115200); } static uint8_t timeToSet[11] = { 0 }; static bool isColonSet = false; static uint8_t hourValue = 99; static uint8_t minuteValue = 99; static uint8_t secondValue = 99; void loop() { // put your main code here, to run repeatedly: if (Serial.available() > 10) { for (uint8_t i = 0; i < 11; i++) { timeToSet[i] = Serial.read(); } Serial.flush(); time_t tt = atol((char*) timeToSet); rt.setTime(rt.TimeZone(tt, 1)); } if (!isColonSet) { writeCharacter(':', 2); writeCharacter(':', 5); isColonSet = true; } if (hourValue != rt.hour()) { hourValue = rt.hour(); writeCharacter((char)((hourValue / 10) + '0'), 0); writeCharacter((char)((hourValue % 10) + '0'), 1); } if (minuteValue != rt.minute()) { minuteValue = rt.minute(); writeCharacter((char)((minuteValue / 10) + '0'), 3); writeCharacter((char)((minuteValue % 10) + '0'), 4); } if (secondValue != rt.second()) { secondValue = rt.second(); writeCharacter((char)((secondValue / 10) + '0'), 6); writeCharacter((char)((secondValue % 10) + '0'), 7); } delay(100); }
There is short video presentation:
Top Comments