axe133 bargraph

Just received my axe133 oled and built it, everything seems to be working ok. Now i wish to attempt to make a bargraph with a center position so i can display from center to right or left but having some difficulties understanding how to do this. My code has three variables stored from a input of a potentiometer and i wish to use these variables to move the bargraph from the center either right or left depending on the input from the analogue in. Can anyone give me some examples of code to do this so i can look at how it is done then i am sure i can proceed from there.
 

hippy

Ex-Staff (retired)
Do you want to have the AXE133Y itself do the bargraph display or do you want it controlled by serial from another PICAXE ?

For serial control ( and for directly connected LCD ) you'll need to determine what characters to put in each display position. You can either have a chunky display with each character having all pixels on or off or a more fine display of varying width bars using CGRAM characters. For direct OLED control you can probably take advantage of the OLED's 'graphics mode' capability.

Two other questions which will help is what is the input value, that is what determines a zero setting, leftwards or rightwards, and what do you want displayed when the value is zero and the display is centred ?

You're probably best off coding for a simple left to right bargraph to start with then using the experience from that to create a centred display. Here's a simulated way to do that ...

Code:
#Picaxe 20M2
#Terminal 4800
#No_Data

Symbol CHARS     = 16 ' 16 character display

Symbol adc       = b0
Symbol pixelsOn  = b1
Symbol charsOn   = b2
Symbol charsToDo = b3
Do
  ReadAdc c.1, adc
  SerTxd( #adc, 9 )
  pixelsOn = CHARS * 5 - 1 * adc / 255 + 1
  charsOn = pixelsOn / 5
  pixelsOn = pixelsOn // 5
  charsToDo = CHARS - charsOn
  Do While charsOn > 0
    SerTxd( "#" )
    charsOn = charsOn - 1
  Loop
  If pixelsOn <> 0 Then
    SerTxd( #pixelsOn )
    charsToDo = charsToDo - 1
  End If
  Do While charsToDo > 0  
    SerTxd( "_" )
    charsToDo = charsToDo - 1
  Loop
  SerTxd( CR, LF )
  Pause 500
Loop
A "#" means a full block character, a "_" means a space character, "1" through "4" means a block character of 1 through 4 pixels wide on from the left. This always has the left most pixel bar set when zero. If you don't want anyting for zero -

pixelsOn = CHARS * 5 * adc / 255
 
Thanks for the reply hippy. First i wish to drive the oled from another 18M2 if possible via the serout. The three variables are stored via the setup procedure of my program where a potentiometer is adjusted three times to give full left position, full right position and center position (roughly the potentiometer is fully CCW for left fully CW for right and roughly in the center for the Center position) When the potentiomer is in the center position i wish to display a character/block in the center of the oled on line 2 and when the potentiomer is moved from center to left or right then the bargraph will move the correct way leaving the center block displayed. Hope this makes sense and not to confusing.
 
Top