x
This website is using cookies. We use cookies to ensure that we give you the best experience on our website. More info. That's Fine
HPC:Factor Logo 
 
Latest Forum Activity

Making use of a 7 segment LCD

1 2 3
I dunk for bananas Page Icon Posted 2023-06-17 7:55 PM
#
Avatar image of I dunk for bananas
H/PC Elite

Posts:
704
Location:
Europe
Status:
The device I'm using has a small four-character 7 segment display, and there appears to be a DLL within the system files used to access this display.
I've writte a program that calls this DLL function and uses the supplied command line argument as the argument to call the DLL function with. The controller itself is a PT6955.

Trying to let anything meaningful show up on the display doesn't work though - only garbled characters show up, and I have no idea how to actually have it display a useful message of any kind.

I did stumble upon a german forum where somebody possibly had success doing what I'm trying right now, this is what they said regarding the display:

Quote
The function itself is simple, it receives 4x8bit, which encode the segments of the display unchanged.


I've also attached a screenshot of what the mapping seems to be.

Does anyone how to make sense of this? I'm at a loss at this point



(1.jpg)



(2.jpg)



Attachments
----------------
Attachments 1.jpg (9KB - 0 downloads)
Attachments 2.jpg (60KB - 0 downloads)
 Top of the page
WinCEDev Page Icon Posted 2023-06-17 10:53 PM
#
Avatar image of WinCEDev
Factorite (Senior)

Posts:
76
Location:
Europe
Status:
They are using a bitwise representation with each bit toggling a display segment.
So say you want to display a zero, you would have to turn on bits 0 to 5, and turn off bits 6 to 7.

The result would be 00011111 in binary, or 0x1F hexadecimal.
The 7th bit is used for the dot, so if you wanted to display 0. you could modify the value to 10011111 (0x9F in hex).

You can use the following site to convert a binary number to hexadecimal: Binary to Hex converter.

Edited by WinCEDev 2023-06-17 10:58 PM
 Top of the page
I dunk for bananas Page Icon Posted 2023-06-17 11:45 PM
#
Avatar image of I dunk for bananas
H/PC Elite

Posts:
704
Location:
Europe
Status:
Thank you! The part that I'm having trouble with is figuring out how to fit all four digits into one function call Is the call done with an array of four 8 bit integers? Or are they concatenated in some way? Whatever I try seems to produce gibberish. I tried out the two thing you suggested, see the attached image!



(Untitled.jpg)



Attachments
----------------
Attachments Untitled.jpg (90KB - 0 downloads)
 Top of the page
WinCEDev Page Icon Posted 2023-06-18 12:07 AM
#
Avatar image of WinCEDev
Factorite (Senior)

Posts:
76
Location:
Europe
Status:
That's odd, could you share the function definition and the code you're using to program the display?
 Top of the page
I dunk for bananas Page Icon Posted 2023-06-18 12:11 AM
#
Avatar image of I dunk for bananas
H/PC Elite

Posts:
704
Location:
Europe
Status:
If by function definition you mean the documentation behind it, there is none sadly, all that I could find it listed on my first post here :(
This is the code I'm using:

#include "windows.h" #include <stdlib.h> typedef void (*LedSetDigitsFn)(int digits); int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow) { HMODULE hDll = LoadLibrary(L"tg_ctrl.dll"); if (hDll == NULL) { return 1; } FARPROC pFunction = GetProcAddress(hDll, L"LedSetDigits"); if (pFunction == NULL) { FreeLibrary(hDll); return 1; } LedSetDigitsFn ledSetDigits = (LedSetDigitsFn)pFunction; int digits = 0; if (lpCmdLine != NULL && lpCmdLine[0] != L'\0') { digits = _wtoi(lpCmdLine); } ledSetDigits(digits); FreeLibrary(hDll); return 0; }


I still haven't figured out how to fit all four digits of the display into one single string

Edited by I dunk for bananas 2023-06-18 12:12 AM
 Top of the page
WinCEDev Page Icon Posted 2023-06-18 12:35 AM
#
Avatar image of WinCEDev
Factorite (Senior)

Posts:
76
Location:
Europe
Status:
Thanks, that clears up a couple of things.

You're using _wtoi to convert the command-line argument to a number, but that function expects a decimal value. The reason I initially gave you a hex value was because I was assuming you were passing the values directly from code.

The digits parameter is a 32-bit int which works out to 4 bytes, one byte per digit. Though, it probably should be an unsigned integer.
Could you try changing your typedef to the following?
typedef void (*LedSetDigitsFn)(unsigned int digits);

Then I think if you pass 4294967295 on the command line it should make all segments light up.

Edited by WinCEDev 2023-06-18 12:37 AM
 Top of the page
I dunk for bananas Page Icon Posted 2023-06-18 12:44 AM
#
Avatar image of I dunk for bananas
H/PC Elite

Posts:
704
Location:
Europe
Status:
Thank you so much!! This is the code now:

#include "windows.h" #include <stdlib.h> typedef void (*LedSetDigitsFn)(unsigned int digits); int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow) { HMODULE hDll = LoadLibrary(L"tg_ctrl.dll"); if (hDll == NULL) { return 1; } FARPROC pFunction = GetProcAddress(hDll, L"LedSetDigits"); if (pFunction == NULL) { FreeLibrary(hDll); return 1; } LedSetDigitsFn ledSetDigits = (LedSetDigitsFn)pFunction; int digits = 0; if (lpCmdLine != NULL && lpCmdLine[0] != L'\0') { digits = _wtoi(lpCmdLine); } ledSetDigits(digits); FreeLibrary(hDll); return 0; }


I tried running it with 4294967295 as an argument but it just gave me this:
Maybe it does have to be called with an array ..? :(

Edited by I dunk for bananas 2023-06-18 12:46 AM




(Untitled.jpg)



Attachments
----------------
Attachments Untitled.jpg (48KB - 0 downloads)
 Top of the page
WinCEDev Page Icon Posted 2023-06-18 1:00 AM
#
Avatar image of WinCEDev
Factorite (Senior)

Posts:
76
Location:
Europe
Status:
Sorry, I forgot something, you also have to change the definition of the digits variable to unsigned:
unsigned int digits = 0;
 Top of the page
I dunk for bananas Page Icon Posted 2023-06-18 1:11 AM
#
Avatar image of I dunk for bananas
H/PC Elite

Posts:
704
Location:
Europe
Status:
WinCEDev - 2023-06-18 1:00 AM


Sorry, I forgot something, you also have to change the definition of the digits variable to unsigned:
unsigned int digits = 0;


Thank you! I made the change but it still shows the same as in the last screenshot I sent
 Top of the page
WinCEDev Page Icon Posted 2023-06-18 1:29 AM
#
Avatar image of WinCEDev
Factorite (Senior)

Posts:
76
Location:
Europe
Status:
I'm still not 100% sure about this, but after some research I think _wtoi doesn't handle unsigned integers.

Just to test, could you try setting digits to 4294967295 directly without using the command line value?
If that works then at least we know we're on the right track.
 Top of the page
I dunk for bananas Page Icon Posted 2023-06-18 9:10 AM
#
Avatar image of I dunk for bananas
H/PC Elite

Posts:
704
Location:
Europe
Status:
I gave it a try, here's the new code:

#include "windows.h" #include <stdlib.h> typedef void (*LedSetDigitsFn)(unsigned int digits); int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow) { HMODULE hDll = LoadLibrary(L"tg_ctrl.dll"); if (hDll == NULL) { return 1; } FARPROC pFunction = GetProcAddress(hDll, L"LedSetDigits"); if (pFunction == NULL) { FreeLibrary(hDll); return 1; } LedSetDigitsFn ledSetDigits = (LedSetDigitsFn)pFunction; unsigned int digits = 4294967295; ledSetDigits(digits); FreeLibrary(hDll); return 0; }




Edited by I dunk for bananas 2023-06-18 9:11 AM




(IMG_20230618_1006312.jpg)



Attachments
----------------
Attachments IMG_20230618_1006312.jpg (47KB - 0 downloads)
 Top of the page
C:Amie Page Icon Posted 2023-06-18 9:05 PM
#
Avatar image of C:Amie
Administrator
H/PC Oracle

Posts:
17,990
Location:
United Kingdom
Status:
What does it do if you clear it and send in:
4294967040
then
2147483392
then
16776960
then
65280
?

Edit: also, does sending in 0 after population clear it?
 Top of the page
I dunk for bananas Page Icon Posted 2023-06-18 9:44 PM
#
Avatar image of I dunk for bananas
H/PC Elite

Posts:
704
Location:
Europe
Status:
C:Amie - 2023-06-18 9:05 PM


What does it do if you clear it and send in:
4294967040
then
2147483392
then
16776960
then
65280
?

Edit: also, does sending in 0 after population clear it?


This is the code I used (in this case it's with the 0, but I tried it with every number you suggested):

#include "windows.h" #include <stdlib.h> typedef void (*LedSetDigitsFn)(unsigned int digits); int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow) { HMODULE hDll = LoadLibrary(L"tg_ctrl.dll"); if (hDll == NULL) { return 1; } FARPROC pFunction = GetProcAddress(hDll, L"LedSetDigits"); if (pFunction == NULL) { FreeLibrary(hDll); return 1; } LedSetDigitsFn ledSetDigits = (LedSetDigitsFn)pFunction; unsigned int digits = 0; ledSetDigits(digits); FreeLibrary(hDll); return 0; }


The result seems to always be the same for some reason

Edited by I dunk for bananas 2023-06-18 9:45 PM




(a.jpg)



Attachments
----------------
Attachments a.jpg (43KB - 0 downloads)
 Top of the page
C:Amie Page Icon Posted 2023-06-18 9:52 PM
#
Avatar image of C:Amie
Administrator
H/PC Oracle

Posts:
17,990
Location:
United Kingdom
Status:
Figured, what else does that DLL export?
When dealing with these serial line displays, unless the API function handles it for you, you have to consider command / mode definition as well as often timing.

Try sending
64
then immediately send
4294967295
on the next line
?
 Top of the page
I dunk for bananas Page Icon Posted 2023-06-18 10:13 PM
#
Avatar image of I dunk for bananas
H/PC Elite

Posts:
704
Location:
Europe
Status:
I believe the DLL should be handling timing, here's the rest of the exports:
The person on the forum thread I found mentioned that the function just needs to be supplied with "4x8bit", which it then displays on the LCD panel "unchanged"

Edited by I dunk for bananas 2023-06-18 10:16 PM




(a.jpg)



Attachments
----------------
Attachments a.jpg (93KB - 0 downloads)
 Top of the page
1 2 3
Jump to forum:
Seconds to generate: 0.328 - Cached queries : 72 - Executed queries : 15