paintballHomepaintballPicturespaintballTechnicalpaintballTournamentpaintballRecreationalpaintballFieldspaintballStorespaintball
paintballBeginner InfopaintballNews And ArticlespaintballLinkspaintballResourcespaintballVideopaintballContact UspaintballSearchpaintball

 
 

What do you think?
Add your comments in WARPIG's TECH TALK FORUMS.

ShotMeter

The ShotMeter
by Rich Kappmeier

Email

Return to Main Article

A Simple LCD Bar Graph

Bar GraphThis code snippet describes a method of creating a simple bar graph display on a Hitachi based Ampire AC162BYA53 LCD display. A display address that is loaded with 255 shows a solid 5x7 block of pixels. For example, if the pulse length desired were 7, this subroutine will assign blocks to display addresses 0-6 and dashes to addresses 7-F of the second line of the display. Please note that I have, in addition to making this snippet more pseudocode, also made it more linear in nature by re-integrating some subroutines. For the original version please consult the downloadable MBasic file on this article's main WARPIG.com page.

CODE
BEEPLENGTH:
Lcdwrite , line1 = "Pulse Length:"
OBJECT = KONFIG.nib1

INDEX = 0
BEEPBAR:
if INDEX <= OBJECT then
BARGRAPH(INDEX) = 255
else
BARGRAPH(INDEX) = "-"
endif
INDEX = INDEX + 1
if INDEX < 16 then BEEPBAR
INDEX = 0
BEEPDISP:
lcdwrite, line2 = [BARGRAPH \ 16]
BEEPBUTT:
pause 200
if PODBUTT = 1 then BEEPPLUS
if LOADERBUTT = 1 then BEEPMINUS
if TANKBUTT = 1 then BEEPEXIT
goto BEEPBUTT
BEEPPLUS:
OBJECT = OBJECT + 1
if OBJECT > 15 then
OBJECT = 0
endif
goto BEEPBAR
BEEPMINUS:
OBJECT = OBJECT – 1
if OBJECT > 15 then
OBJECT = 15
endif
goto BEEPBAR
BEEPEXIT:
KONFIG.nib1 = OBJECT
END OF CODE

COMMENTS
; section - subroutine initialization
; write “Pulse Length:” to the first line of the LCD
; copy high nibble of KONFIG variable into OBJECT byte variable.
; The high nibble (bits 4-7) of the KONFIG byte is where the pulse
; length is stored after it is read from the on-board eeprom
; OBJECT is a word sized temporary variable
; copy 0 into INDEX byte variable

; section - load characters into BARGRAPH 16-byte array
; when INDEX <= OBJECT copy 255 into byte numbered INDEX
; of the BARGRAPH array. Assigns “blocks” to pulse count.
; when INDEX > OBJECT copy “-“ into byte numbered INDEX
; of the BARGRAPH array. Assigns “-“ to digits > pulse count
; end of if…then
; increment INDEX
; when INDEX = 16 drop through to next section, otherwise
; loop to BEEPBAR
; copy 0 to INDEX

; section - display bar graph on line2
; write all 16 bytes of BARGRAPH array to line2 of LCD
; section - button loop
; debounce pause for buttons, 200ms
; when POD button pressed branch to BEEPPLUS
; when LOADER button pressed branch to BEEPMINUS
; when TANK button pressed branch to BEEPEXIT
; loop

; section - increment OBJECT byte variable
; increment OBJECT
; when OBJECT > 15
; wrap around to 0
; end of if…then

; section - decrement OBJECT byte variable
; decrement OBJECT
; when OBJECT > 15
; wrap around to 15
; end of if…then

; section - store OBJECT in high nibble of KONFIG byte
; copy OBJECT to high nibble of KONFIG byte

 

 

 


Copyright © 1992-2019 Corinthian Media Services.

WARPIG's webmasters can be reached through our feedback form.  All articles and images are copyrighted and may not be redistributed without the written permission of their original creators and Corinthian Media Services. The WARPIG paintball page is a collection of information and pointers to sources from around the internet and other locations. As such, Corinthian Media Services makes no claims to the trustworthiness or reliability of said information. The information contained in, and referenced by WARPIG, should not be used as a substitute for safety information from trained professionals in the paintball industry.