• Blog
  • Parts Sources
  • Form Test
VccGnd

7LED: A quick reference Android app for 7-segment LED symbols

9/12/2012

0 Comments

 
Continuing my fixation with 7-segment LEDs, 7LED is an Android app that serves as a quick reference for 7-segment LED symbols.  Ignoring decimal points, It shows all possible symbols, along with the selected symbol's corresponding lit segments (A-G) and bit encodings.  Here's a video that shows how it works in the Android emulator (a bit fuzzier than on a real device due to screen capture process):

7LED_demo by VccGnd
You can click on the cell of a symbol, or if the small cell sizes make it difficult to click precisely, you can use the trackpad area at the bottom to move the selection cursor.  The About Box displays the bit encoding values, for inclusion in a C program.

You can download 7LED from this page by clicking on its Google play icon.

As mentioned in a previous post, it is possible to simulate 7-segment LEDs with ASCII text.  Here is a console app, 7LEDTest.c, for verifying encodings referenced from the 7LED Android app.  The code also shows the bit encoding constants (LED_A .. LED_G) that can be used with your microcontroller code.
#include <stdio.h>
#include <stdlib.h>

#define LED_A 0x01
#define LED_B 0x02
#define LED_C 0x04
#define LED_D 0x08
#define LED_E 0x10
#define LED_F 0x20
#define LED_G 0x40

static void show(int encoding)
{
    printf(" %c \n",
        (encoding & LED_A) ? '_' : ' ');

    printf("%c%c%c\n",
        (encoding & LED_F) ? '|' : ' ',
        (encoding & LED_G) ? '_' : ' ',
        (encoding & LED_B) ? '|' : ' ');

    printf("%c%c%c\n",
        (encoding & LED_E) ? '|' : ' ',
        (encoding & LED_D) ? '_' : ' ',
        (encoding & LED_C) ? '|' : ' ');
}

int main(int argc, char **argv)
{
    int i;
    char *sEncoding;
    int encoding = 0;

    if (argc < 2)
    {
        printf("7LEDTest encoding [moreEncodings...]\n");
        printf("\tencoding can be decimal or hexadecimal\n");
        printf("\te.g. 7LEDTest 127\n");
        printf("\te.g. 7LEDTest 0x7F\n");

        return 0;
    }

    for(i=1; i<argc; i++)
    {
        sEncoding = argv[i];
        encoding = strtol(sEncoding, NULL, 0);
        
        show(encoding);
    }

    return 0;
}

7LEDTest.c
File Size: 1 kb
File Type: c
Download File

7LEDTest.c has been tested on both Windows (Visual C++ Express) and on Macs (gcc).  You give it decimal or hexadecimal arguments, and you can give it multiple encodings.  For example:
%./7LEDTest 118 63 56 119
   
|_|
| |
 _ 
| |
|_|
   
|  
|_ 
 _ 
|_|
| |
And again, but with arguments in hexadecimal:
%./7LEDTest 0x38 0x79 0x5e 0x7

|  
|_ 
 _ 
|_ 
|_ 

 _|
|_|
 _
  |
  |
0 Comments

    VccGnd

    Hardware with a software twist.

    Archives

    February 2014
    January 2014
    September 2012
    August 2012
    July 2012

    Categories

    All
    7LED
    Android
    Ascii
    Crystal Free USB
    Crystal-Free USB
    Dev Boards
    MSP430
    Overviews
    PCB
    PIC8
    Sourcing

    RSS Feed

Powered by Create your own unique website with customizable templates.