Initial commit

OLED worked, displaying large digits worked, reading VCC level worked, started refactoring. Does not currently build, but I'm too tired to figure it out right now.
This commit is contained in:
Mark van Renswoude 2017-08-01 23:29:57 +02:00
commit b20ce09a2c
32 changed files with 2714 additions and 0 deletions

5
.gitignore vendored Normal file
View File

@ -0,0 +1,5 @@
*.bak
*.kicad_pcb-bak
KiCad/export/
*.sublime-workspace
Source/.pioenvs/

View File

@ -0,0 +1,43 @@
(module Housings_SOIC:SOIC-8_3.9x4.9mm_Pitch1.27mm (layer F.Cu) (tedit 597F6E61)
(descr "8-Lead Plastic Small Outline (SN) - Narrow, 3.90 mm Body [SOIC] (see Microchip Packaging Specification 00000049BS.pdf)")
(tags "SOIC 1.27")
(attr smd)
(fp_text reference U1 (at 0 -3.5) (layer F.SilkS)
(effects (font (size 1 1) (thickness 0.15)))
)
(fp_text value ATTINY85-20SU (at 0 3.5) (layer F.Fab)
(effects (font (size 1 1) (thickness 0.15)))
)
(fp_line (start -2.075 -2.525) (end -3.475 -2.525) (layer F.SilkS) (width 0.15))
(fp_line (start -2.075 2.575) (end 2.075 2.575) (layer F.SilkS) (width 0.15))
(fp_line (start -2.075 -2.575) (end 2.075 -2.575) (layer F.SilkS) (width 0.15))
(fp_line (start -2.075 2.575) (end -2.075 2.43) (layer F.SilkS) (width 0.15))
(fp_line (start 2.075 2.575) (end 2.075 2.43) (layer F.SilkS) (width 0.15))
(fp_line (start 2.075 -2.575) (end 2.075 -2.43) (layer F.SilkS) (width 0.15))
(fp_line (start -2.075 -2.575) (end -2.075 -2.525) (layer F.SilkS) (width 0.15))
(fp_line (start -3.73 2.7) (end 3.73 2.7) (layer F.CrtYd) (width 0.05))
(fp_line (start -3.73 -2.7) (end 3.73 -2.7) (layer F.CrtYd) (width 0.05))
(fp_line (start 3.73 -2.7) (end 3.73 2.7) (layer F.CrtYd) (width 0.05))
(fp_line (start -3.73 -2.7) (end -3.73 2.7) (layer F.CrtYd) (width 0.05))
(fp_line (start -1.95 -1.45) (end -0.95 -2.45) (layer F.Fab) (width 0.1))
(fp_line (start -1.95 2.45) (end -1.95 -1.45) (layer F.Fab) (width 0.1))
(fp_line (start 1.95 2.45) (end -1.95 2.45) (layer F.Fab) (width 0.1))
(fp_line (start 1.95 -2.45) (end 1.95 2.45) (layer F.Fab) (width 0.1))
(fp_line (start -0.95 -2.45) (end 1.95 -2.45) (layer F.Fab) (width 0.1))
(fp_text user %R (at 0 0) (layer F.Fab)
(effects (font (size 1 1) (thickness 0.15)))
)
(pad 8 smd rect (at 5.75 -1.905) (size 1.55 0.6) (layers F.Cu F.Paste F.Mask))
(pad 7 smd rect (at 5.75 -0.635) (size 1.55 0.6) (layers F.Cu F.Paste F.Mask))
(pad 6 smd rect (at 5.75 0.635) (size 1.55 0.6) (layers F.Cu F.Paste F.Mask))
(pad 5 smd rect (at 5.75 1.905) (size 1.55 0.6) (layers F.Cu F.Paste F.Mask))
(pad 4 smd rect (at -2.7 1.905) (size 1.55 0.6) (layers F.Cu F.Paste F.Mask))
(pad 3 smd rect (at -2.7 0.635) (size 1.55 0.6) (layers F.Cu F.Paste F.Mask))
(pad 2 smd rect (at -2.7 -0.635) (size 1.55 0.6) (layers F.Cu F.Paste F.Mask))
(pad 1 smd rect (at -2.7 -1.905) (size 1.55 0.6) (layers F.Cu F.Paste F.Mask))
(model ${KISYS3DMOD}/Housings_SOIC.3dshapes/SOIC-8_3.9x4.9mm_Pitch1.27mm.wrl
(at (xyz 0 0 0))
(scale (xyz 1 1 1))
(rotate (xyz 0 0 0))
)
)

138
KiCad/GameCounter-cache.lib Normal file
View File

@ -0,0 +1,138 @@
EESchema-LIBRARY Version 2.3
#encoding utf-8
#
# +BATT
#
DEF +BATT #PWR 0 0 Y Y 1 F P
F0 "#PWR" 0 -150 50 H I C CNN
F1 "+BATT" 0 140 50 H V C CNN
F2 "" 0 0 50 H I C CNN
F3 "" 0 0 50 H I C CNN
DRAW
P 2 0 1 0 -30 50 0 100 N
P 2 0 1 0 0 0 0 100 N
P 2 0 1 0 0 100 30 50 N
X +BATT 1 0 0 0 U 50 50 1 1 W N
ENDDRAW
ENDDEF
#
# ATTINY25-20SU
#
DEF ATTINY25-20SU U 0 40 Y Y 1 F N
F0 "U" -1150 400 50 H V C CNN
F1 "ATTINY25-20SU" 1000 -400 50 H V C CNN
F2 "Housings_SOIC:SOIC-8_3.9x4.9mm_Pitch1.27mm" 950 0 50 H I C CIN
F3 "" 0 0 50 H I C CNN
ALIAS ATTINY45-20SU ATTINY85-20SU
DRAW
S -1200 350 1200 -350 0 1 10 f
X PB5(~RESET~/dW/ADC0/PCINT5) 1 -1350 -250 150 R 40 40 1 1 B
X PB3(XTAL1/CLKI/~OC1B~/ADC3/PCINT3) 2 -1350 -50 150 R 40 40 1 1 B
X PB4(XTAL2/CLKO/OC1B/ADC2/PCINT4) 3 -1350 -150 150 R 40 40 1 1 B
X GND 4 1350 -250 150 L 40 40 1 1 W
X PB0(MOSI/DI/SDA/AIN0/OC0A/~OC1A~/AREF/PCINT0) 5 -1350 250 150 R 40 40 1 1 B
X PB1(MISO/DO/AIN1/OC0B/OC1A/PCINT1) 6 -1350 150 150 R 40 40 1 1 B
X PB2(SCK/USCK/SCL/T0/INT0/ADC1/PCINT2) 7 -1350 50 150 R 40 40 1 1 B
X VCC 8 1350 250 150 L 40 40 1 1 W
ENDDRAW
ENDDEF
#
# C
#
DEF C C 0 10 N Y 1 F N
F0 "C" 25 100 50 H V L CNN
F1 "C" 25 -100 50 H V L CNN
F2 "" 38 -150 50 H I C CNN
F3 "" 0 0 50 H I C CNN
$FPLIST
C_*
$ENDFPLIST
DRAW
P 2 0 1 20 -80 -30 80 -30 N
P 2 0 1 20 -80 30 80 30 N
X ~ 1 0 150 110 D 50 50 1 1 P
X ~ 2 0 -150 110 U 50 50 1 1 P
ENDDRAW
ENDDEF
#
# CONN_01X04_FEMALE
#
DEF CONN_01X04_FEMALE J 0 40 Y N 1 F N
F0 "J" 0 400 50 H V C CNN
F1 "CONN_01X04_FEMALE" 100 -400 50 H V C CNN
F2 "" 0 300 50 H I C CNN
F3 "" 0 300 50 H I C CNN
DRAW
A 150 -300 50 901 -901 0 1 0 N 150 -250 150 -350
A 150 -100 50 901 -901 0 1 0 N 150 -50 150 -150
A 150 100 50 901 -901 0 1 0 N 150 150 150 50
A 150 300 50 901 -901 0 1 0 N 150 350 150 250
X 1 1 -100 300 200 R 50 50 1 1 P
X 2 2 -100 100 200 R 50 50 1 1 P
X 3 3 -100 -100 200 R 50 50 1 1 P
X 4 4 -100 -300 200 R 50 50 1 1 P
ENDDRAW
ENDDEF
#
# GND
#
DEF GND #PWR 0 0 Y Y 1 F P
F0 "#PWR" 0 -250 50 H I C CNN
F1 "GND" 0 -150 50 H V C CNN
F2 "" 0 0 50 H I C CNN
F3 "" 0 0 50 H I C CNN
DRAW
P 6 0 1 0 0 0 0 -50 50 -50 0 -100 -50 -50 0 -50 N
X GND 1 0 0 0 D 50 50 1 1 W N
ENDDRAW
ENDDEF
#
# PWR_FLAG
#
DEF PWR_FLAG #FLG 0 0 N N 1 F P
F0 "#FLG" 0 75 50 H I C CNN
F1 "PWR_FLAG" 0 150 50 H V C CNN
F2 "" 0 0 50 H I C CNN
F3 "" 0 0 50 H I C CNN
DRAW
X pwr 1 0 0 0 U 50 50 0 0 w
P 6 0 1 0 0 0 0 50 -40 75 0 100 40 75 0 50 N
ENDDRAW
ENDDEF
#
# R
#
DEF R R 0 0 N Y 1 F N
F0 "R" 80 0 50 V V C CNN
F1 "R" 0 0 50 V V C CNN
F2 "" -70 0 50 V I C CNN
F3 "" 0 0 50 H I C CNN
$FPLIST
R_*
R_*
$ENDFPLIST
DRAW
S -40 -100 40 100 0 1 10 N
X ~ 1 0 150 50 D 50 50 1 1 P
X ~ 2 0 -150 50 U 50 50 1 1 P
ENDDRAW
ENDDEF
#
# SW_Push
#
DEF SW_Push SW 0 40 N N 1 F N
F0 "SW" 50 100 50 H V L CNN
F1 "SW_Push" 0 -60 50 H V C CNN
F2 "" 0 200 50 H I C CNN
F3 "" 0 200 50 H I C CNN
DRAW
C -80 0 20 0 1 0 N
C 80 0 20 0 1 0 N
P 2 0 1 0 0 50 0 120 N
P 2 0 1 0 100 50 -100 50 N
X 1 1 -200 0 100 R 50 50 0 1 P
X 2 2 200 0 100 L 50 50 0 1 P
ENDDRAW
ENDDEF
#
#End Library

531
KiCad/GameCounter.kicad_pcb Normal file
View File

@ -0,0 +1,531 @@
(kicad_pcb (version 20170123) (host pcbnew "(2017-07-28 revision 75cda5021)-makepkg")
(general
(thickness 1.6)
(drawings 7)
(tracks 42)
(zones 0)
(modules 7)
(nets 9)
)
(page A4)
(title_block
(title "Game Counter")
(company "Mark van Renswoude")
)
(layers
(0 F.Cu signal)
(31 B.Cu signal)
(32 B.Adhes user hide)
(33 F.Adhes user hide)
(34 B.Paste user hide)
(35 F.Paste user hide)
(36 B.SilkS user hide)
(37 F.SilkS user hide)
(38 B.Mask user hide)
(39 F.Mask user hide)
(40 Dwgs.User user hide)
(41 Cmts.User user hide)
(42 Eco1.User user hide)
(43 Eco2.User user hide)
(44 Edge.Cuts user hide)
(45 Margin user hide)
(46 B.CrtYd user hide)
(47 F.CrtYd user hide)
(48 B.Fab user hide)
(49 F.Fab user hide)
)
(setup
(last_trace_width 0.5)
(trace_clearance 0)
(zone_clearance 0.508)
(zone_45_only no)
(trace_min 0.2)
(segment_width 0.2)
(edge_width 0.2)
(via_size 0.6)
(via_drill 0.4)
(via_min_size 0.4)
(via_min_drill 0.3)
(uvia_size 0.3)
(uvia_drill 0.1)
(uvias_allowed no)
(uvia_min_size 0.2)
(uvia_min_drill 0.1)
(pcb_text_width 0.3)
(pcb_text_size 1.5 1.5)
(mod_edge_width 0.15)
(mod_text_size 1 1)
(mod_text_width 0.15)
(pad_size 1.524 0.5)
(pad_drill 0)
(pad_to_mask_clearance 0.2)
(aux_axis_origin 0 0)
(visible_elements 7FFFFFFF)
(pcbplotparams
(layerselection 0x00000_7fffffff)
(usegerberextensions false)
(excludeedgelayer true)
(linewidth 0.100000)
(plotframeref false)
(viasonmask false)
(mode 1)
(useauxorigin false)
(hpglpennumber 1)
(hpglpenspeed 20)
(hpglpendiameter 15)
(psnegative true)
(psa4output false)
(plotreference true)
(plotvalue true)
(plotinvisibletext false)
(padsonsilk false)
(subtractmaskfromsilk false)
(outputformat 4)
(mirror false)
(drillshape 1)
(scaleselection 1)
(outputdirectory ./export/))
)
(net 0 "")
(net 1 GND)
(net 2 +BATT)
(net 3 "Net-(J1-Pad4)")
(net 4 "Net-(J1-Pad3)")
(net 5 "Net-(R1-Pad2)")
(net 6 "Net-(SW1-Pad1)")
(net 7 "Net-(SW2-Pad1)")
(net 8 "Net-(SW3-Pad1)")
(net_class Default "This is the default net class."
(clearance 0)
(trace_width 0.5)
(via_dia 0.6)
(via_drill 0.4)
(uvia_dia 0.3)
(uvia_drill 0.1)
(add_net +BATT)
(add_net GND)
(add_net "Net-(J1-Pad3)")
(add_net "Net-(J1-Pad4)")
(add_net "Net-(R1-Pad2)")
(add_net "Net-(SW1-Pad1)")
(add_net "Net-(SW2-Pad1)")
(add_net "Net-(SW3-Pad1)")
)
(module Resistors_SMD:R_0603_HandSoldering (layer F.Cu) (tedit 58E0A804) (tstamp 5980814D)
(at 62.146 24.384)
(descr "Resistor SMD 0603, hand soldering")
(tags "resistor 0603")
(path /597F3D75)
(attr smd)
(fp_text reference R1 (at 0 -1.45) (layer F.SilkS)
(effects (font (size 1 1) (thickness 0.15)))
)
(fp_text value 10k (at 0 1.55) (layer F.Fab)
(effects (font (size 1 1) (thickness 0.15)))
)
(fp_line (start 1.95 0.7) (end -1.96 0.7) (layer F.CrtYd) (width 0.05))
(fp_line (start 1.95 0.7) (end 1.95 -0.7) (layer F.CrtYd) (width 0.05))
(fp_line (start -1.96 -0.7) (end -1.96 0.7) (layer F.CrtYd) (width 0.05))
(fp_line (start -1.96 -0.7) (end 1.95 -0.7) (layer F.CrtYd) (width 0.05))
(fp_line (start -0.5 -0.68) (end 0.5 -0.68) (layer F.SilkS) (width 0.12))
(fp_line (start 0.5 0.68) (end -0.5 0.68) (layer F.SilkS) (width 0.12))
(fp_line (start -0.8 -0.4) (end 0.8 -0.4) (layer F.Fab) (width 0.1))
(fp_line (start 0.8 -0.4) (end 0.8 0.4) (layer F.Fab) (width 0.1))
(fp_line (start 0.8 0.4) (end -0.8 0.4) (layer F.Fab) (width 0.1))
(fp_line (start -0.8 0.4) (end -0.8 -0.4) (layer F.Fab) (width 0.1))
(fp_text user %R (at 0 0) (layer F.Fab)
(effects (font (size 0.4 0.4) (thickness 0.075)))
)
(pad 2 smd rect (at 1.1 0) (size 1.2 0.9) (layers F.Cu F.Paste F.Mask)
(net 5 "Net-(R1-Pad2)"))
(pad 1 smd rect (at -1.1 0) (size 1.2 0.9) (layers F.Cu F.Paste F.Mask)
(net 2 +BATT))
(model ${KISYS3DMOD}/Resistors_SMD.3dshapes/R_0603.wrl
(at (xyz 0 0 0))
(scale (xyz 1 1 1))
(rotate (xyz 0 0 0))
)
)
(module Capacitors_ThroughHole:C_Disc_D3.0mm_W1.6mm_P2.50mm (layer F.Cu) (tedit 597BC7C2) (tstamp 59808124)
(at 65.278 37.592 90)
(descr "C, Disc series, Radial, pin pitch=2.50mm, , diameter*width=3.0*1.6mm^2, Capacitor, http://www.vishay.com/docs/45233/krseries.pdf")
(tags "C Disc series Radial pin pitch 2.50mm diameter 3.0mm width 1.6mm Capacitor")
(path /597F4561)
(fp_text reference C1 (at 1.25 -2.11 90) (layer F.SilkS)
(effects (font (size 1 1) (thickness 0.15)))
)
(fp_text value C (at 1.25 2.11 90) (layer F.Fab)
(effects (font (size 1 1) (thickness 0.15)))
)
(fp_text user %R (at 1.25 0 90) (layer F.Fab)
(effects (font (size 1 1) (thickness 0.15)))
)
(fp_line (start 3.55 -1.15) (end -1.05 -1.15) (layer F.CrtYd) (width 0.05))
(fp_line (start 3.55 1.15) (end 3.55 -1.15) (layer F.CrtYd) (width 0.05))
(fp_line (start -1.05 1.15) (end 3.55 1.15) (layer F.CrtYd) (width 0.05))
(fp_line (start -1.05 -1.15) (end -1.05 1.15) (layer F.CrtYd) (width 0.05))
(fp_line (start 0.663 0.861) (end 1.837 0.861) (layer F.SilkS) (width 0.12))
(fp_line (start 0.663 -0.861) (end 1.837 -0.861) (layer F.SilkS) (width 0.12))
(fp_line (start 2.75 -0.8) (end -0.25 -0.8) (layer F.Fab) (width 0.1))
(fp_line (start 2.75 0.8) (end 2.75 -0.8) (layer F.Fab) (width 0.1))
(fp_line (start -0.25 0.8) (end 2.75 0.8) (layer F.Fab) (width 0.1))
(fp_line (start -0.25 -0.8) (end -0.25 0.8) (layer F.Fab) (width 0.1))
(pad 2 thru_hole circle (at 2.5 0 90) (size 1.6 1.6) (drill 0.8) (layers *.Cu *.Mask)
(net 1 GND))
(pad 1 thru_hole circle (at 0 0 90) (size 1.6 1.6) (drill 0.8) (layers *.Cu *.Mask)
(net 2 +BATT))
(model ${KISYS3DMOD}/Capacitors_THT.3dshapes/C_Disc_D3.0mm_W1.6mm_P2.50mm.wrl
(at (xyz 0 0 0))
(scale (xyz 1 1 1))
(rotate (xyz 0 0 0))
)
)
(module Pin_Headers:Pin_Header_Straight_1x04_Pitch2.54mm (layer F.Cu) (tedit 59650532) (tstamp 5980813C)
(at 41.91 32.512)
(descr "Through hole straight pin header, 1x04, 2.54mm pitch, single row")
(tags "Through hole pin header THT 1x04 2.54mm single row")
(path /597F2CA0)
(fp_text reference J1 (at 0 -2.33) (layer F.SilkS)
(effects (font (size 1 1) (thickness 0.15)))
)
(fp_text value "SSD1306 I2C" (at 0 9.95) (layer F.Fab)
(effects (font (size 1 1) (thickness 0.15)))
)
(fp_text user %R (at 0 3.81 90) (layer F.Fab)
(effects (font (size 1 1) (thickness 0.15)))
)
(fp_line (start 1.8 -1.8) (end -1.8 -1.8) (layer F.CrtYd) (width 0.05))
(fp_line (start 1.8 9.4) (end 1.8 -1.8) (layer F.CrtYd) (width 0.05))
(fp_line (start -1.8 9.4) (end 1.8 9.4) (layer F.CrtYd) (width 0.05))
(fp_line (start -1.8 -1.8) (end -1.8 9.4) (layer F.CrtYd) (width 0.05))
(fp_line (start -1.33 -1.33) (end 0 -1.33) (layer F.SilkS) (width 0.12))
(fp_line (start -1.33 0) (end -1.33 -1.33) (layer F.SilkS) (width 0.12))
(fp_line (start -1.33 1.27) (end 1.33 1.27) (layer F.SilkS) (width 0.12))
(fp_line (start 1.33 1.27) (end 1.33 8.95) (layer F.SilkS) (width 0.12))
(fp_line (start -1.33 1.27) (end -1.33 8.95) (layer F.SilkS) (width 0.12))
(fp_line (start -1.33 8.95) (end 1.33 8.95) (layer F.SilkS) (width 0.12))
(fp_line (start -1.27 -0.635) (end -0.635 -1.27) (layer F.Fab) (width 0.1))
(fp_line (start -1.27 8.89) (end -1.27 -0.635) (layer F.Fab) (width 0.1))
(fp_line (start 1.27 8.89) (end -1.27 8.89) (layer F.Fab) (width 0.1))
(fp_line (start 1.27 -1.27) (end 1.27 8.89) (layer F.Fab) (width 0.1))
(fp_line (start -0.635 -1.27) (end 1.27 -1.27) (layer F.Fab) (width 0.1))
(pad 4 thru_hole oval (at 0 7.62) (size 1.7 1.7) (drill 1) (layers *.Cu *.Mask)
(net 3 "Net-(J1-Pad4)"))
(pad 3 thru_hole oval (at 0 5.08) (size 1.7 1.7) (drill 1) (layers *.Cu *.Mask)
(net 4 "Net-(J1-Pad3)"))
(pad 2 thru_hole oval (at 0 2.54) (size 1.7 1.7) (drill 1) (layers *.Cu *.Mask)
(net 2 +BATT))
(pad 1 thru_hole rect (at 0 0) (size 1.7 1.7) (drill 1) (layers *.Cu *.Mask)
(net 1 GND))
(model ${KISYS3DMOD}/Pin_Headers.3dshapes/Pin_Header_Straight_1x04_Pitch2.54mm.wrl
(at (xyz 0 0 0))
(scale (xyz 1 1 1))
(rotate (xyz 0 0 0))
)
)
(module ATTiny85_HandSoldering:SOIC-8_3.9x4.9mm_Pitch1.27mm (layer F.Cu) (tedit 597F6E61) (tstamp 59817D06)
(at 61.214 33.272 270)
(descr "8-Lead Plastic Small Outline (SN) - Narrow, 3.90 mm Body [SOIC] (see Microchip Packaging Specification 00000049BS.pdf)")
(tags "SOIC 1.27")
(path /597F285D)
(attr smd)
(fp_text reference U1 (at 0 -3.5 270) (layer F.SilkS)
(effects (font (size 1 1) (thickness 0.15)))
)
(fp_text value ATTINY85-20SU (at 0 3.5 270) (layer F.Fab)
(effects (font (size 1 1) (thickness 0.15)))
)
(fp_line (start -2.075 -2.525) (end -3.475 -2.525) (layer F.SilkS) (width 0.15))
(fp_line (start -2.075 2.575) (end 2.075 2.575) (layer F.SilkS) (width 0.15))
(fp_line (start -2.075 -2.575) (end 2.075 -2.575) (layer F.SilkS) (width 0.15))
(fp_line (start -2.075 2.575) (end -2.075 2.43) (layer F.SilkS) (width 0.15))
(fp_line (start 2.075 2.575) (end 2.075 2.43) (layer F.SilkS) (width 0.15))
(fp_line (start 2.075 -2.575) (end 2.075 -2.43) (layer F.SilkS) (width 0.15))
(fp_line (start -2.075 -2.575) (end -2.075 -2.525) (layer F.SilkS) (width 0.15))
(fp_line (start -3.73 2.7) (end 3.73 2.7) (layer F.CrtYd) (width 0.05))
(fp_line (start -3.73 -2.7) (end 3.73 -2.7) (layer F.CrtYd) (width 0.05))
(fp_line (start 3.73 -2.7) (end 3.73 2.7) (layer F.CrtYd) (width 0.05))
(fp_line (start -3.73 -2.7) (end -3.73 2.7) (layer F.CrtYd) (width 0.05))
(fp_line (start -1.95 -1.45) (end -0.95 -2.45) (layer F.Fab) (width 0.1))
(fp_line (start -1.95 2.45) (end -1.95 -1.45) (layer F.Fab) (width 0.1))
(fp_line (start 1.95 2.45) (end -1.95 2.45) (layer F.Fab) (width 0.1))
(fp_line (start 1.95 -2.45) (end 1.95 2.45) (layer F.Fab) (width 0.1))
(fp_line (start -0.95 -2.45) (end 1.95 -2.45) (layer F.Fab) (width 0.1))
(fp_text user %R (at 0 0 270) (layer F.Fab)
(effects (font (size 1 1) (thickness 0.15)))
)
(pad 8 smd rect (at 5.75 -1.905 270) (size 1.55 0.6) (layers F.Cu F.Paste F.Mask)
(net 2 +BATT))
(pad 7 smd rect (at 5.75 -0.635 270) (size 1.55 0.6) (layers F.Cu F.Paste F.Mask)
(net 4 "Net-(J1-Pad3)"))
(pad 6 smd rect (at 5.75 0.635 270) (size 1.55 0.6) (layers F.Cu F.Paste F.Mask)
(net 6 "Net-(SW1-Pad1)"))
(pad 5 smd rect (at 5.75 1.905 270) (size 1.55 0.6) (layers F.Cu F.Paste F.Mask)
(net 3 "Net-(J1-Pad4)"))
(pad 4 smd rect (at -2.7 1.905 270) (size 1.55 0.6) (layers F.Cu F.Paste F.Mask)
(net 1 GND))
(pad 3 smd rect (at -2.7 0.635 270) (size 1.55 0.6) (layers F.Cu F.Paste F.Mask)
(net 8 "Net-(SW3-Pad1)"))
(pad 2 smd rect (at -2.7 -0.635 270) (size 1.55 0.6) (layers F.Cu F.Paste F.Mask)
(net 7 "Net-(SW2-Pad1)"))
(pad 1 smd rect (at -2.7 -1.905 270) (size 1.55 0.6) (layers F.Cu F.Paste F.Mask)
(net 5 "Net-(R1-Pad2)"))
(model ${KISYS3DMOD}/Housings_SOIC.3dshapes/SOIC-8_3.9x4.9mm_Pitch1.27mm.wrl
(at (xyz 0 0 0))
(scale (xyz 1 1 1))
(rotate (xyz 0 0 0))
)
)
(module Switch_SMD_5x5mm:Switch_SMD_5x5mm (layer F.Cu) (tedit 597F70C9) (tstamp 5981AF9A)
(at 51.518 39.474 180)
(path /597F567B)
(fp_text reference SW1 (at 0 0.5 180) (layer F.SilkS)
(effects (font (size 1 1) (thickness 0.15)))
)
(fp_text value SW_Push (at 0 -0.5 180) (layer F.Fab)
(effects (font (size 1 1) (thickness 0.15)))
)
(pad 1 smd oval (at -4 -3 180) (size 1.524 0.5) (layers F.Cu F.Paste F.Mask)
(net 6 "Net-(SW1-Pad1)"))
(pad 1 smd oval (at 2.5 -3 180) (size 1.524 0.5) (layers F.Cu F.Paste F.Mask)
(net 6 "Net-(SW1-Pad1)"))
(pad 2 smd oval (at -4 -6.7 180) (size 1.524 0.5) (layers F.Cu F.Paste F.Mask)
(net 1 GND))
(pad 2 smd oval (at 2.5 -6.7 180) (size 1.524 0.5) (layers F.Cu F.Paste F.Mask)
(net 1 GND))
)
(module Switch_SMD_5x5mm:Switch_SMD_5x5mm (layer F.Cu) (tedit 597F70C9) (tstamp 5981AFA2)
(at 51.518 23.67 180)
(path /597F574D)
(fp_text reference SW2 (at 0 0.5 180) (layer F.SilkS)
(effects (font (size 1 1) (thickness 0.15)))
)
(fp_text value SW_Push (at 0 -0.5 180) (layer F.Fab)
(effects (font (size 1 1) (thickness 0.15)))
)
(pad 2 smd oval (at 2.5 -6.7 180) (size 1.524 0.5) (layers F.Cu F.Paste F.Mask)
(net 1 GND))
(pad 2 smd oval (at -4 -6.7 180) (size 1.524 0.5) (layers F.Cu F.Paste F.Mask)
(net 1 GND))
(pad 1 smd oval (at 2.5 -3 180) (size 1.524 0.5) (layers F.Cu F.Paste F.Mask)
(net 7 "Net-(SW2-Pad1)"))
(pad 1 smd oval (at -4 -3 180) (size 1.524 0.5) (layers F.Cu F.Paste F.Mask)
(net 7 "Net-(SW2-Pad1)"))
)
(module Switch_SMD_5x5mm:Switch_SMD_5x5mm (layer F.Cu) (tedit 597F70C9) (tstamp 5981AFAA)
(at 51.518 31.544 180)
(path /597F5781)
(fp_text reference SW3 (at 0 0.5 180) (layer F.SilkS)
(effects (font (size 1 1) (thickness 0.15)))
)
(fp_text value SW_Push (at 0 -0.5 180) (layer F.Fab)
(effects (font (size 1 1) (thickness 0.15)))
)
(pad 1 smd oval (at -4 -3 180) (size 1.524 0.5) (layers F.Cu F.Paste F.Mask)
(net 8 "Net-(SW3-Pad1)"))
(pad 1 smd oval (at 2.5 -3 180) (size 1.524 0.5) (layers F.Cu F.Paste F.Mask)
(net 8 "Net-(SW3-Pad1)"))
(pad 2 smd oval (at -4 -6.7 180) (size 1.524 0.5) (layers F.Cu F.Paste F.Mask)
(net 1 GND))
(pad 2 smd oval (at 2.5 -6.7 180) (size 1.524 0.5) (layers F.Cu F.Paste F.Mask)
(net 1 GND))
)
(gr_line (start 39.116 36.322) (end 66.548 36.322) (layer Eco1.User) (width 0.2))
(gr_line (start 39.116 22.606) (end 66.548 50.038) (layer Eco1.User) (width 0.2))
(gr_line (start 39.116 50.038) (end 66.548 22.606) (layer Eco1.User) (width 0.2))
(gr_line (start 39.116 50.038) (end 39.116 22.606) (layer Dwgs.User) (width 0.2))
(gr_line (start 66.548 50.038) (end 39.116 50.038) (layer Dwgs.User) (width 0.2))
(gr_line (start 66.548 22.606) (end 66.548 50.038) (layer Dwgs.User) (width 0.2))
(gr_line (start 39.116 22.606) (end 66.548 22.606) (layer Dwgs.User) (width 0.2))
(segment (start 46.736 34.544) (end 46.736 38.1) (width 0.5) (layer B.Cu) (net 1))
(via (at 46.736 34.544) (size 0.6) (drill 0.4) (layers F.Cu B.Cu) (net 1))
(via (at 46.736 38.1) (size 0.6) (drill 0.4) (layers F.Cu B.Cu) (net 1))
(segment (start 45.420001 24.683999) (end 45.72 24.384) (width 0.5) (layer F.Cu) (net 2))
(segment (start 40.132 29.972) (end 45.420001 24.683999) (width 0.5) (layer F.Cu) (net 2))
(segment (start 40.132 35.627919) (end 40.132 29.972) (width 0.5) (layer F.Cu) (net 2))
(segment (start 52.324 24.384) (end 45.72 24.384) (width 0.5) (layer B.Cu) (net 2))
(via (at 45.72 24.384) (size 0.6) (drill 0.4) (layers F.Cu B.Cu) (net 2))
(segment (start 52.324 24.384) (end 60.96 24.384) (width 0.5) (layer F.Cu) (net 2))
(via (at 52.324 24.384) (size 0.6) (drill 0.4) (layers F.Cu B.Cu) (net 2))
(segment (start 41.91 35.052) (end 40.707919 35.052) (width 0.5) (layer F.Cu) (net 2))
(segment (start 40.707919 35.052) (end 40.132 35.627919) (width 0.5) (layer F.Cu) (net 2))
(segment (start 62.992 40.386) (end 63.03 40.386) (width 0.5) (layer F.Cu) (net 2))
(segment (start 40.132 35.627919) (end 40.132 40.894) (width 0.5) (layer F.Cu) (net 2))
(segment (start 40.132 40.894) (end 42.926 43.688) (width 0.5) (layer F.Cu) (net 2))
(segment (start 42.926 43.688) (end 59.69 43.688) (width 0.5) (layer F.Cu) (net 2))
(segment (start 63.119 40.297) (end 63.119 39.022) (width 0.5) (layer F.Cu) (net 2))
(segment (start 59.69 43.688) (end 62.992 40.386) (width 0.5) (layer F.Cu) (net 2))
(segment (start 63.03 40.386) (end 63.119 40.297) (width 0.5) (layer F.Cu) (net 2))
(segment (start 65.278 37.592) (end 64.549 37.592) (width 0.5) (layer F.Cu) (net 2))
(segment (start 64.549 37.592) (end 63.119 39.022) (width 0.5) (layer F.Cu) (net 2))
(segment (start 58.674 40.132) (end 41.91 40.132) (width 0.5) (layer F.Cu) (net 3))
(segment (start 59.309 39.022) (end 59.309 39.497) (width 0.5) (layer F.Cu) (net 3))
(segment (start 59.309 39.497) (end 58.674 40.132) (width 0.5) (layer F.Cu) (net 3))
(segment (start 61.849 39.022) (end 61.849 37.719) (width 0.5) (layer F.Cu) (net 4))
(segment (start 61.849 37.719) (end 60.872001 36.742001) (width 0.5) (layer F.Cu) (net 4))
(segment (start 60.872001 36.742001) (end 45.299999 36.742001) (width 0.5) (layer F.Cu) (net 4))
(segment (start 45.299999 36.742001) (end 44.45 37.592) (width 0.5) (layer F.Cu) (net 4))
(segment (start 44.45 37.592) (end 41.91 37.592) (width 0.5) (layer F.Cu) (net 4))
(segment (start 63.246 24.384) (end 63.16 24.47) (width 0.5) (layer F.Cu) (net 5))
(segment (start 63.16 24.47) (end 63.16 30.531) (width 0.5) (layer F.Cu) (net 5))
(segment (start 63.16 30.531) (end 63.119 30.572) (width 0.5) (layer F.Cu) (net 5))
(segment (start 58.872 42.474) (end 60.579 40.767) (width 0.5) (layer F.Cu) (net 6))
(segment (start 60.579 40.767) (end 60.579 39.022) (width 0.5) (layer F.Cu) (net 6))
(segment (start 56.03 42.474) (end 58.872 42.474) (width 0.5) (layer F.Cu) (net 6))
(segment (start 59.944 26.67) (end 61.849 28.575) (width 0.5) (layer F.Cu) (net 7))
(segment (start 61.849 28.575) (end 61.849 30.572) (width 0.5) (layer F.Cu) (net 7))
(segment (start 56.03 26.67) (end 59.944 26.67) (width 0.5) (layer F.Cu) (net 7))
(segment (start 60.579 32.893) (end 58.928 34.544) (width 0.5) (layer F.Cu) (net 8))
(segment (start 58.928 34.544) (end 56.03 34.544) (width 0.5) (layer F.Cu) (net 8))
(segment (start 60.579 30.572) (end 60.579 32.893) (width 0.5) (layer F.Cu) (net 8))
(segment (start 56.03 34.544) (end 55.518 34.544) (width 0.5) (layer F.Cu) (net 8))
(zone (net 1) (net_name GND) (layer F.Cu) (tstamp 0) (hatch edge 0.508)
(connect_pads (clearance 0.508))
(min_thickness 0.254)
(fill yes (arc_segments 16) (thermal_gap 0.508) (thermal_bridge_width 0.508))
(polygon
(pts
(xy 39.116 22.606) (xy 67.31 22.606) (xy 67.31 50.038) (xy 39.116 50.038)
)
)
(filled_polygon
(pts
(xy 67.183 49.911) (xy 39.243 49.911) (xy 39.243 46.434518) (xy 47.660213 46.434518) (xy 47.790407 46.709987)
(xy 48.049992 46.943033) (xy 48.379 47.059) (xy 48.891 47.059) (xy 48.891 46.299) (xy 49.145 46.299)
(xy 49.145 47.059) (xy 49.657 47.059) (xy 49.986008 46.943033) (xy 50.245593 46.709987) (xy 50.375787 46.434518)
(xy 54.160213 46.434518) (xy 54.290407 46.709987) (xy 54.549992 46.943033) (xy 54.879 47.059) (xy 55.391 47.059)
(xy 55.391 46.299) (xy 55.645 46.299) (xy 55.645 47.059) (xy 56.157 47.059) (xy 56.486008 46.943033)
(xy 56.745593 46.709987) (xy 56.875787 46.434518) (xy 56.745412 46.299) (xy 55.645 46.299) (xy 55.391 46.299)
(xy 54.290588 46.299) (xy 54.160213 46.434518) (xy 50.375787 46.434518) (xy 50.245412 46.299) (xy 49.145 46.299)
(xy 48.891 46.299) (xy 47.790588 46.299) (xy 47.660213 46.434518) (xy 39.243 46.434518) (xy 39.243 45.913482)
(xy 47.660213 45.913482) (xy 47.790588 46.049) (xy 48.891 46.049) (xy 48.891 45.289) (xy 49.145 45.289)
(xy 49.145 46.049) (xy 50.245412 46.049) (xy 50.375787 45.913482) (xy 54.160213 45.913482) (xy 54.290588 46.049)
(xy 55.391 46.049) (xy 55.391 45.289) (xy 55.645 45.289) (xy 55.645 46.049) (xy 56.745412 46.049)
(xy 56.875787 45.913482) (xy 56.745593 45.638013) (xy 56.486008 45.404967) (xy 56.157 45.289) (xy 55.645 45.289)
(xy 55.391 45.289) (xy 54.879 45.289) (xy 54.549992 45.404967) (xy 54.290407 45.638013) (xy 54.160213 45.913482)
(xy 50.375787 45.913482) (xy 50.245593 45.638013) (xy 49.986008 45.404967) (xy 49.657 45.289) (xy 49.145 45.289)
(xy 48.891 45.289) (xy 48.379 45.289) (xy 48.049992 45.404967) (xy 47.790407 45.638013) (xy 47.660213 45.913482)
(xy 39.243 45.913482) (xy 39.243 29.972) (xy 39.246999 29.972) (xy 39.247 29.972005) (xy 39.247 35.627914)
(xy 39.246999 35.627919) (xy 39.247 35.627924) (xy 39.247 40.893995) (xy 39.246999 40.894) (xy 39.289105 41.105674)
(xy 39.314367 41.232675) (xy 39.421351 41.392789) (xy 39.50621 41.51979) (xy 42.300208 44.313787) (xy 42.30021 44.31379)
(xy 42.587325 44.505633) (xy 42.643516 44.51681) (xy 42.926 44.573001) (xy 42.926005 44.573) (xy 59.689995 44.573)
(xy 59.69 44.573001) (xy 59.972484 44.51681) (xy 60.028675 44.505633) (xy 60.31579 44.31379) (xy 63.541269 41.08831)
(xy 63.65579 41.01179) (xy 63.744787 40.922792) (xy 63.74479 40.92279) (xy 63.936633 40.635675) (xy 63.94781 40.579484)
(xy 64.004001 40.297) (xy 64.004 40.296995) (xy 64.004 40.064456) (xy 64.017157 40.044765) (xy 64.06644 39.797)
(xy 64.06644 39.32614) (xy 64.549348 38.843232) (xy 64.991309 39.02675) (xy 65.562187 39.027248) (xy 66.0898 38.809243)
(xy 66.493824 38.405923) (xy 66.71275 37.878691) (xy 66.713248 37.307813) (xy 66.495243 36.7802) (xy 66.091923 36.376176)
(xy 66.025456 36.348577) (xy 66.032005 36.345864) (xy 66.106139 36.099745) (xy 65.278 35.271605) (xy 64.449861 36.099745)
(xy 64.523995 36.345864) (xy 64.530483 36.348196) (xy 64.4662 36.374757) (xy 64.062176 36.778077) (xy 64.007421 36.909943)
(xy 63.92321 36.96621) (xy 63.923208 36.966213) (xy 63.289861 37.59956) (xy 62.819 37.59956) (xy 62.714382 37.62037)
(xy 62.666633 37.380325) (xy 62.581775 37.253326) (xy 62.47479 37.09321) (xy 62.474787 37.093208) (xy 61.497791 36.116211)
(xy 61.473148 36.099745) (xy 61.210676 35.924368) (xy 61.154485 35.913191) (xy 60.872001 35.857) (xy 60.871996 35.857001)
(xy 45.300004 35.857001) (xy 45.299999 35.857) (xy 44.961324 35.924368) (xy 44.674209 36.116211) (xy 44.674207 36.116214)
(xy 44.08342 36.707) (xy 43.099432 36.707) (xy 42.989147 36.541946) (xy 42.659974 36.322) (xy 42.989147 36.102054)
(xy 43.311054 35.620285) (xy 43.424093 35.052) (xy 43.323046 34.544) (xy 47.593631 34.544) (xy 47.660998 34.882675)
(xy 47.852841 35.16979) (xy 48.139956 35.361633) (xy 48.478631 35.429) (xy 49.557369 35.429) (xy 49.896044 35.361633)
(xy 50.183159 35.16979) (xy 50.375002 34.882675) (xy 50.442369 34.544) (xy 50.375002 34.205325) (xy 50.183159 33.91821)
(xy 49.896044 33.726367) (xy 49.557369 33.659) (xy 48.478631 33.659) (xy 48.139956 33.726367) (xy 47.852841 33.91821)
(xy 47.660998 34.205325) (xy 47.593631 34.544) (xy 43.323046 34.544) (xy 43.311054 34.483715) (xy 42.989147 34.001946)
(xy 42.945223 33.972597) (xy 43.119698 33.900327) (xy 43.298327 33.721699) (xy 43.395 33.48831) (xy 43.395 32.79775)
(xy 43.23625 32.639) (xy 42.037 32.639) (xy 42.037 32.659) (xy 41.783 32.659) (xy 41.783 32.639)
(xy 41.763 32.639) (xy 41.763 32.385) (xy 41.783 32.385) (xy 41.783 31.18575) (xy 42.037 31.18575)
(xy 42.037 32.385) (xy 43.23625 32.385) (xy 43.395 32.22625) (xy 43.395 31.53569) (xy 43.298327 31.302301)
(xy 43.119698 31.123673) (xy 42.886309 31.027) (xy 42.19575 31.027) (xy 42.037 31.18575) (xy 41.783 31.18575)
(xy 41.62425 31.027) (xy 41.017 31.027) (xy 41.017 30.630518) (xy 47.660213 30.630518) (xy 47.790407 30.905987)
(xy 48.049992 31.139033) (xy 48.379 31.255) (xy 48.891 31.255) (xy 48.891 30.495) (xy 49.145 30.495)
(xy 49.145 31.255) (xy 49.657 31.255) (xy 49.986008 31.139033) (xy 50.245593 30.905987) (xy 50.375787 30.630518)
(xy 54.160213 30.630518) (xy 54.290407 30.905987) (xy 54.549992 31.139033) (xy 54.879 31.255) (xy 55.391 31.255)
(xy 55.391 30.495) (xy 55.645 30.495) (xy 55.645 31.255) (xy 56.157 31.255) (xy 56.486008 31.139033)
(xy 56.745593 30.905987) (xy 56.768391 30.85775) (xy 58.374 30.85775) (xy 58.374 31.473309) (xy 58.470673 31.706698)
(xy 58.649301 31.885327) (xy 58.88269 31.982) (xy 59.02325 31.982) (xy 59.182 31.82325) (xy 59.182 30.699)
(xy 58.53275 30.699) (xy 58.374 30.85775) (xy 56.768391 30.85775) (xy 56.875787 30.630518) (xy 56.745412 30.495)
(xy 55.645 30.495) (xy 55.391 30.495) (xy 54.290588 30.495) (xy 54.160213 30.630518) (xy 50.375787 30.630518)
(xy 50.245412 30.495) (xy 49.145 30.495) (xy 48.891 30.495) (xy 47.790588 30.495) (xy 47.660213 30.630518)
(xy 41.017 30.630518) (xy 41.017 30.33858) (xy 41.246097 30.109482) (xy 47.660213 30.109482) (xy 47.790588 30.245)
(xy 48.891 30.245) (xy 48.891 29.485) (xy 49.145 29.485) (xy 49.145 30.245) (xy 50.245412 30.245)
(xy 50.375787 30.109482) (xy 54.160213 30.109482) (xy 54.290588 30.245) (xy 55.391 30.245) (xy 55.391 29.485)
(xy 55.645 29.485) (xy 55.645 30.245) (xy 56.745412 30.245) (xy 56.875787 30.109482) (xy 56.745593 29.834013)
(xy 56.563673 29.670691) (xy 58.374 29.670691) (xy 58.374 30.28625) (xy 58.53275 30.445) (xy 59.182 30.445)
(xy 59.182 29.32075) (xy 59.02325 29.162) (xy 58.88269 29.162) (xy 58.649301 29.258673) (xy 58.470673 29.437302)
(xy 58.374 29.670691) (xy 56.563673 29.670691) (xy 56.486008 29.600967) (xy 56.157 29.485) (xy 55.645 29.485)
(xy 55.391 29.485) (xy 54.879 29.485) (xy 54.549992 29.600967) (xy 54.290407 29.834013) (xy 54.160213 30.109482)
(xy 50.375787 30.109482) (xy 50.245593 29.834013) (xy 49.986008 29.600967) (xy 49.657 29.485) (xy 49.145 29.485)
(xy 48.891 29.485) (xy 48.379 29.485) (xy 48.049992 29.600967) (xy 47.790407 29.834013) (xy 47.660213 30.109482)
(xy 41.246097 30.109482) (xy 44.685579 26.67) (xy 47.593631 26.67) (xy 47.660998 27.008675) (xy 47.852841 27.29579)
(xy 48.139956 27.487633) (xy 48.478631 27.555) (xy 49.557369 27.555) (xy 49.896044 27.487633) (xy 50.183159 27.29579)
(xy 50.375002 27.008675) (xy 50.442369 26.67) (xy 50.375002 26.331325) (xy 50.183159 26.04421) (xy 49.896044 25.852367)
(xy 49.557369 25.785) (xy 48.478631 25.785) (xy 48.139956 25.852367) (xy 47.852841 26.04421) (xy 47.660998 26.331325)
(xy 47.593631 26.67) (xy 44.685579 26.67) (xy 46.045788 25.309791) (xy 46.045791 25.309789) (xy 46.128835 25.226744)
(xy 46.248943 25.177117) (xy 46.512192 24.914327) (xy 46.654838 24.570799) (xy 46.654839 24.569167) (xy 51.388838 24.569167)
(xy 51.530883 24.912943) (xy 51.793673 25.176192) (xy 52.137201 25.318838) (xy 52.509167 25.319162) (xy 52.630569 25.269)
(xy 59.97295 25.269) (xy 59.988191 25.291809) (xy 60.198235 25.432157) (xy 60.446 25.48144) (xy 61.646 25.48144)
(xy 61.893765 25.432157) (xy 62.103809 25.291809) (xy 62.146 25.228666) (xy 62.188191 25.291809) (xy 62.275 25.349813)
(xy 62.275 27.749421) (xy 60.56979 26.04421) (xy 60.282675 25.852367) (xy 60.226484 25.84119) (xy 59.944 25.784999)
(xy 59.943995 25.785) (xy 54.978631 25.785) (xy 54.639956 25.852367) (xy 54.352841 26.04421) (xy 54.160998 26.331325)
(xy 54.093631 26.67) (xy 54.160998 27.008675) (xy 54.352841 27.29579) (xy 54.639956 27.487633) (xy 54.978631 27.555)
(xy 59.57742 27.555) (xy 60.964 28.941579) (xy 60.964 29.166467) (xy 60.879 29.14956) (xy 60.279 29.14956)
(xy 60.031235 29.198843) (xy 59.952028 29.251768) (xy 59.73531 29.162) (xy 59.59475 29.162) (xy 59.436 29.32075)
(xy 59.436 30.445) (xy 59.456 30.445) (xy 59.456 30.699) (xy 59.436 30.699) (xy 59.436 31.82325)
(xy 59.59475 31.982) (xy 59.694 31.982) (xy 59.694 32.526421) (xy 58.56142 33.659) (xy 54.978631 33.659)
(xy 54.639956 33.726367) (xy 54.352841 33.91821) (xy 54.160998 34.205325) (xy 54.093631 34.544) (xy 54.160998 34.882675)
(xy 54.352841 35.16979) (xy 54.639956 35.361633) (xy 54.978631 35.429) (xy 58.927995 35.429) (xy 58.928 35.429001)
(xy 59.210484 35.37281) (xy 59.266675 35.361633) (xy 59.55379 35.16979) (xy 59.848356 34.875223) (xy 63.831035 34.875223)
(xy 63.858222 35.445454) (xy 64.024136 35.846005) (xy 64.270255 35.920139) (xy 65.098395 35.092) (xy 65.457605 35.092)
(xy 66.285745 35.920139) (xy 66.531864 35.846005) (xy 66.724965 35.308777) (xy 66.697778 34.738546) (xy 66.531864 34.337995)
(xy 66.285745 34.263861) (xy 65.457605 35.092) (xy 65.098395 35.092) (xy 64.270255 34.263861) (xy 64.024136 34.337995)
(xy 63.831035 34.875223) (xy 59.848356 34.875223) (xy 60.639324 34.084255) (xy 64.449861 34.084255) (xy 65.278 34.912395)
(xy 66.106139 34.084255) (xy 66.032005 33.838136) (xy 65.494777 33.645035) (xy 64.924546 33.672222) (xy 64.523995 33.838136)
(xy 64.449861 34.084255) (xy 60.639324 34.084255) (xy 61.204787 33.518792) (xy 61.20479 33.51879) (xy 61.396633 33.231675)
(xy 61.396634 33.231674) (xy 61.464001 32.893) (xy 61.464 32.892995) (xy 61.464 31.977533) (xy 61.549 31.99444)
(xy 62.149 31.99444) (xy 62.396765 31.945157) (xy 62.484 31.886868) (xy 62.571235 31.945157) (xy 62.819 31.99444)
(xy 63.419 31.99444) (xy 63.666765 31.945157) (xy 63.876809 31.804809) (xy 64.017157 31.594765) (xy 64.06644 31.347)
(xy 64.06644 29.797) (xy 64.045 29.689213) (xy 64.045 25.441857) (xy 64.093765 25.432157) (xy 64.303809 25.291809)
(xy 64.444157 25.081765) (xy 64.49344 24.834) (xy 64.49344 23.934) (xy 64.444157 23.686235) (xy 64.303809 23.476191)
(xy 64.093765 23.335843) (xy 63.846 23.28656) (xy 62.646 23.28656) (xy 62.398235 23.335843) (xy 62.188191 23.476191)
(xy 62.146 23.539334) (xy 62.103809 23.476191) (xy 61.893765 23.335843) (xy 61.646 23.28656) (xy 60.446 23.28656)
(xy 60.198235 23.335843) (xy 59.988191 23.476191) (xy 59.97295 23.499) (xy 52.630822 23.499) (xy 52.510799 23.449162)
(xy 52.138833 23.448838) (xy 51.795057 23.590883) (xy 51.531808 23.853673) (xy 51.389162 24.197201) (xy 51.388838 24.569167)
(xy 46.654839 24.569167) (xy 46.655162 24.198833) (xy 46.513117 23.855057) (xy 46.250327 23.591808) (xy 45.906799 23.449162)
(xy 45.534833 23.448838) (xy 45.191057 23.590883) (xy 44.927808 23.853673) (xy 44.877434 23.974986) (xy 44.794211 24.058209)
(xy 44.794209 24.058212) (xy 39.50621 29.34621) (xy 39.314367 29.633325) (xy 39.314367 29.633326) (xy 39.246999 29.972)
(xy 39.243 29.972) (xy 39.243 22.733) (xy 67.183 22.733)
)
)
(filled_polygon
(pts
(xy 47.790407 37.708013) (xy 47.660213 37.983482) (xy 47.790588 38.119) (xy 48.891 38.119) (xy 48.891 38.097)
(xy 49.145 38.097) (xy 49.145 38.119) (xy 50.245412 38.119) (xy 50.375787 37.983482) (xy 50.245593 37.708013)
(xy 50.155355 37.627001) (xy 54.380645 37.627001) (xy 54.290407 37.708013) (xy 54.160213 37.983482) (xy 54.290588 38.119)
(xy 55.391 38.119) (xy 55.391 38.097) (xy 55.645 38.097) (xy 55.645 38.119) (xy 56.745412 38.119)
(xy 56.875787 37.983482) (xy 56.745593 37.708013) (xy 56.655355 37.627001) (xy 58.871043 37.627001) (xy 58.761235 37.648843)
(xy 58.551191 37.789191) (xy 58.410843 37.999235) (xy 58.36156 38.247) (xy 58.36156 39.19286) (xy 58.30742 39.247)
(xy 43.099432 39.247) (xy 42.989147 39.081946) (xy 42.659974 38.862) (xy 42.989147 38.642054) (xy 43.081045 38.504518)
(xy 47.660213 38.504518) (xy 47.790407 38.779987) (xy 48.049992 39.013033) (xy 48.379 39.129) (xy 48.891 39.129)
(xy 48.891 38.369) (xy 49.145 38.369) (xy 49.145 39.129) (xy 49.657 39.129) (xy 49.986008 39.013033)
(xy 50.245593 38.779987) (xy 50.375787 38.504518) (xy 54.160213 38.504518) (xy 54.290407 38.779987) (xy 54.549992 39.013033)
(xy 54.879 39.129) (xy 55.391 39.129) (xy 55.391 38.369) (xy 55.645 38.369) (xy 55.645 39.129)
(xy 56.157 39.129) (xy 56.486008 39.013033) (xy 56.745593 38.779987) (xy 56.875787 38.504518) (xy 56.745412 38.369)
(xy 55.645 38.369) (xy 55.391 38.369) (xy 54.290588 38.369) (xy 54.160213 38.504518) (xy 50.375787 38.504518)
(xy 50.245412 38.369) (xy 49.145 38.369) (xy 48.891 38.369) (xy 47.790588 38.369) (xy 47.660213 38.504518)
(xy 43.081045 38.504518) (xy 43.099432 38.477) (xy 44.449995 38.477) (xy 44.45 38.477001) (xy 44.732484 38.42081)
(xy 44.788675 38.409633) (xy 45.07579 38.21779) (xy 45.666578 37.627001) (xy 47.880645 37.627001)
)
)
)
)

158
KiCad/GameCounter.net Normal file
View File

@ -0,0 +1,158 @@
(export (version D)
(design
(source P:\Arduino\GameCounter\GameCounter.sch)
(date "31-7-2017 19:56:04")
(tool "Eeschema (2017-07-28 revision 75cda5021)-makepkg")
(sheet (number 1) (name /) (tstamps /)
(title_block
(title "Game Counter")
(company "Mark van Renswoude")
(rev)
(date)
(source GameCounter.sch)
(comment (number 1) (value ""))
(comment (number 2) (value ""))
(comment (number 3) (value ""))
(comment (number 4) (value "")))))
(components
(comp (ref U1)
(value ATTINY85-20SU)
(footprint ATTiny85_HandSoldering:SOIC-8_3.9x4.9mm_Pitch1.27mm)
(libsource (lib atmel) (part ATTINY85-20SU))
(sheetpath (names /) (tstamps /))
(tstamp 597F285D))
(comp (ref J1)
(value "SSD1306 I2C")
(footprint Pin_Headers:Pin_Header_Straight_1x04_Pitch2.54mm)
(libsource (lib conn) (part CONN_01X04_FEMALE))
(sheetpath (names /) (tstamps /))
(tstamp 597F2CA0))
(comp (ref R1)
(value 10k)
(footprint Resistors_SMD:R_0603_HandSoldering)
(libsource (lib device) (part R))
(sheetpath (names /) (tstamps /))
(tstamp 597F3D75))
(comp (ref C1)
(value C)
(footprint Capacitors_ThroughHole:C_Disc_D3.0mm_W1.6mm_P2.50mm)
(libsource (lib device) (part C))
(sheetpath (names /) (tstamps /))
(tstamp 597F4561))
(comp (ref SW1)
(value SW_Push)
(footprint Switch_SMD_5x5mm:Switch_SMD_5x5mm)
(libsource (lib switches) (part SW_Push))
(sheetpath (names /) (tstamps /))
(tstamp 597F567B))
(comp (ref SW2)
(value SW_Push)
(footprint Switch_SMD_5x5mm:Switch_SMD_5x5mm)
(libsource (lib switches) (part SW_Push))
(sheetpath (names /) (tstamps /))
(tstamp 597F574D))
(comp (ref SW3)
(value SW_Push)
(footprint Switch_SMD_5x5mm:Switch_SMD_5x5mm)
(libsource (lib switches) (part SW_Push))
(sheetpath (names /) (tstamps /))
(tstamp 597F5781)))
(libparts
(libpart (lib atmel) (part ATTINY25-20SU)
(aliases
(alias ATTINY45-20SU)
(alias ATTINY85-20SU))
(description "SO8 Wide, 2k Flash, 128B SRAM, 128B EEPROM, Debug Wire")
(docs http://www.atmel.com/images/atmel-2586-avr-8-bit-microcontroller-attiny25-attiny45-attiny85_datasheet.pdf)
(fields
(field (name Reference) U)
(field (name Value) ATTINY25-20SU)
(field (name Footprint) Housings_SOIC:SOIC-8_3.9x4.9mm_Pitch1.27mm))
(pins
(pin (num 1) (name "PB5(~RESET~/dW/ADC0/PCINT5)") (type BiDi))
(pin (num 2) (name "PB3(XTAL1/CLKI/~OC1B~/ADC3/PCINT3)") (type BiDi))
(pin (num 3) (name "PB4(XTAL2/CLKO/OC1B/ADC2/PCINT4)") (type BiDi))
(pin (num 4) (name GND) (type power_in))
(pin (num 5) (name "PB0(MOSI/DI/SDA/AIN0/OC0A/~OC1A~/AREF/PCINT0)") (type BiDi))
(pin (num 6) (name "PB1(MISO/DO/AIN1/OC0B/OC1A/PCINT1)") (type BiDi))
(pin (num 7) (name "PB2(SCK/USCK/SCL/T0/INT0/ADC1/PCINT2)") (type BiDi))
(pin (num 8) (name VCC) (type power_in))))
(libpart (lib device) (part C)
(description "Unpolarized capacitor")
(footprints
(fp C_*))
(fields
(field (name Reference) C)
(field (name Value) C))
(pins
(pin (num 1) (name ~) (type passive))
(pin (num 2) (name ~) (type passive))))
(libpart (lib conn) (part CONN_01X04_FEMALE)
(description "Generic Female Connector, Single Row, 01x04, socket header")
(fields
(field (name Reference) J)
(field (name Value) CONN_01X04_FEMALE))
(pins
(pin (num 1) (name 1) (type passive))
(pin (num 2) (name 2) (type passive))
(pin (num 3) (name 3) (type passive))
(pin (num 4) (name 4) (type passive))))
(libpart (lib device) (part R)
(description Resistor)
(footprints
(fp R_*)
(fp R_*))
(fields
(field (name Reference) R)
(field (name Value) R))
(pins
(pin (num 1) (name ~) (type passive))
(pin (num 2) (name ~) (type passive))))
(libpart (lib switches) (part SW_Push)
(description "Push button switch, generic, two pins")
(fields
(field (name Reference) SW)
(field (name Value) SW_Push))
(pins
(pin (num 1) (name 1) (type passive))
(pin (num 2) (name 2) (type passive)))))
(libraries
(library (logical switches)
(uri "C:\\Program Files\\KiCad\\share\\kicad\\library\\switches.lib"))
(library (logical atmel)
(uri "C:\\Program Files\\KiCad\\share\\kicad\\library\\atmel.lib"))
(library (logical conn)
(uri "C:\\Program Files\\KiCad\\share\\kicad\\library\\conn.lib"))
(library (logical device)
(uri "C:\\Program Files\\KiCad\\share\\kicad\\library\\device.lib")))
(nets
(net (code 1) (name "Net-(SW2-Pad1)")
(node (ref SW2) (pin 1))
(node (ref U1) (pin 2)))
(net (code 2) (name "Net-(SW1-Pad1)")
(node (ref U1) (pin 6))
(node (ref SW1) (pin 1)))
(net (code 3) (name GND)
(node (ref J1) (pin 1))
(node (ref U1) (pin 4))
(node (ref C1) (pin 2))
(node (ref SW2) (pin 2))
(node (ref SW3) (pin 2))
(node (ref SW1) (pin 2)))
(net (code 4) (name "Net-(SW3-Pad1)")
(node (ref U1) (pin 3))
(node (ref SW3) (pin 1)))
(net (code 5) (name "Net-(R1-Pad2)")
(node (ref R1) (pin 2))
(node (ref U1) (pin 1)))
(net (code 6) (name +BATT)
(node (ref C1) (pin 1))
(node (ref R1) (pin 1))
(node (ref U1) (pin 8))
(node (ref J1) (pin 2)))
(net (code 7) (name "Net-(J1-Pad4)")
(node (ref J1) (pin 4))
(node (ref U1) (pin 5)))
(net (code 8) (name "Net-(J1-Pad3)")
(node (ref J1) (pin 3))
(node (ref U1) (pin 7)))))

61
KiCad/GameCounter.pro Normal file
View File

@ -0,0 +1,61 @@
update=31-7-2017 15:11:54
version=1
last_client=kicad
[pcbnew]
version=1
LastNetListRead=
UseCmpFile=1
PadDrill=0.600000000000
PadDrillOvalY=0.600000000000
PadSizeH=1.500000000000
PadSizeV=1.500000000000
PcbTextSizeV=1.500000000000
PcbTextSizeH=1.500000000000
PcbTextThickness=0.300000000000
ModuleTextSizeV=1.000000000000
ModuleTextSizeH=1.000000000000
ModuleTextSizeThickness=0.150000000000
SolderMaskClearance=0.000000000000
SolderMaskMinWidth=0.000000000000
DrawSegmentWidth=0.200000000000
BoardOutlineThickness=0.100000000000
ModuleOutlineThickness=0.150000000000
[cvpcb]
version=1
NetIExt=net
[general]
version=1
[eeschema]
version=1
LibDir=
[eeschema/libraries]
LibName1=power
LibName2=device
LibName3=transistors
LibName4=conn
LibName5=linear
LibName6=regul
LibName7=74xx
LibName8=cmos4000
LibName9=adc-dac
LibName10=memory
LibName11=xilinx
LibName12=microcontrollers
LibName13=dsp
LibName14=microchip
LibName15=analog_switches
LibName16=motorola
LibName17=texas
LibName18=intel
LibName19=audio
LibName20=interface
LibName21=digital-audio
LibName22=philips
LibName23=display
LibName24=cypress
LibName25=siliconi
LibName26=opto
LibName27=atmel
LibName28=contrib
LibName29=valves
LibName30=C:/Program Files/KiCad/share/kicad/library/switches

336
KiCad/GameCounter.sch Normal file
View File

@ -0,0 +1,336 @@
EESchema Schematic File Version 2
LIBS:power
LIBS:device
LIBS:transistors
LIBS:conn
LIBS:linear
LIBS:regul
LIBS:74xx
LIBS:cmos4000
LIBS:adc-dac
LIBS:memory
LIBS:xilinx
LIBS:microcontrollers
LIBS:dsp
LIBS:microchip
LIBS:analog_switches
LIBS:motorola
LIBS:texas
LIBS:intel
LIBS:audio
LIBS:interface
LIBS:digital-audio
LIBS:philips
LIBS:display
LIBS:cypress
LIBS:siliconi
LIBS:opto
LIBS:atmel
LIBS:contrib
LIBS:valves
LIBS:switches
LIBS:GameCounter-cache
EELAYER 26 0
EELAYER END
$Descr A4 11693 8268
encoding utf-8
Sheet 1 1
Title "Game Counter"
Date ""
Rev ""
Comp "Mark van Renswoude"
Comment1 ""
Comment2 ""
Comment3 ""
Comment4 ""
$EndDescr
$Comp
L PWR_FLAG #FLG01
U 1 1 597F2770
P 10550 800
F 0 "#FLG01" H 10550 875 50 0001 C CNN
F 1 "PWR_FLAG" H 10550 974 50 0000 C CNN
F 2 "" H 10550 800 50 0001 C CNN
F 3 "" H 10550 800 50 0001 C CNN
1 10550 800
1 0 0 -1
$EndComp
$Comp
L PWR_FLAG #FLG02
U 1 1 597F2792
P 10900 950
F 0 "#FLG02" H 10900 1025 50 0001 C CNN
F 1 "PWR_FLAG" H 10900 1123 50 0000 C CNN
F 2 "" H 10900 950 50 0001 C CNN
F 3 "" H 10900 950 50 0001 C CNN
1 10900 950
-1 0 0 1
$EndComp
$Comp
L +BATT #PWR010
U 1 1 597F27C7
P 10900 800
F 0 "#PWR010" H 10900 650 50 0001 C CNN
F 1 "+BATT" H 10915 973 50 0000 C CNN
F 2 "" H 10900 800 50 0001 C CNN
F 3 "" H 10900 800 50 0001 C CNN
1 10900 800
1 0 0 -1
$EndComp
$Comp
L GND #PWR09
U 1 1 597F27F0
P 10550 950
F 0 "#PWR09" H 10550 700 50 0001 C CNN
F 1 "GND" H 10555 777 50 0000 C CNN
F 2 "" H 10550 950 50 0001 C CNN
F 3 "" H 10550 950 50 0001 C CNN
1 10550 950
1 0 0 -1
$EndComp
$Comp
L ATTINY85-20SU U1
U 1 1 597F285D
P 5550 2950
F 0 "U1" H 5550 3467 50 0000 C CNN
F 1 "ATTINY85-20SU" H 5550 3376 50 0000 C CNN
F 2 "ATTiny85_HandSoldering:SOIC-8_3.9x4.9mm_Pitch1.27mm" H 6500 2950 50 0001 C CIN
F 3 "" H 5550 2950 50 0001 C CNN
1 5550 2950
1 0 0 -1
$EndComp
$Comp
L GND #PWR08
U 1 1 597F2A68
P 7050 3350
F 0 "#PWR08" H 7050 3100 50 0001 C CNN
F 1 "GND" H 7055 3177 50 0000 C CNN
F 2 "" H 7050 3350 50 0001 C CNN
F 3 "" H 7050 3350 50 0001 C CNN
1 7050 3350
1 0 0 -1
$EndComp
$Comp
L +BATT #PWR07
U 1 1 597F2A75
P 7050 2650
F 0 "#PWR07" H 7050 2500 50 0001 C CNN
F 1 "+BATT" H 7065 2823 50 0000 C CNN
F 2 "" H 7050 2650 50 0001 C CNN
F 3 "" H 7050 2650 50 0001 C CNN
1 7050 2650
1 0 0 -1
$EndComp
$Comp
L CONN_01X04_FEMALE J1
U 1 1 597F2CA0
P 3200 3000
F 0 "J1" H 3219 2475 50 0000 C CNN
F 1 "SSD1306 I2C" H 3219 2566 50 0000 C CNN
F 2 "Pin_Headers:Pin_Header_Straight_1x04_Pitch2.54mm" H 3200 3300 50 0001 C CNN
F 3 "" H 3200 3300 50 0001 C CNN
1 3200 3000
-1 0 0 1
$EndComp
$Comp
L GND #PWR02
U 1 1 597F2E4C
P 3550 3300
F 0 "#PWR02" H 3550 3050 50 0001 C CNN
F 1 "GND" H 3555 3127 50 0000 C CNN
F 2 "" H 3550 3300 50 0001 C CNN
F 3 "" H 3550 3300 50 0001 C CNN
1 3550 3300
1 0 0 -1
$EndComp
$Comp
L +BATT #PWR01
U 1 1 597F2E5B
P 3550 3100
F 0 "#PWR01" H 3550 2950 50 0001 C CNN
F 1 "+BATT" H 3565 3273 50 0000 C CNN
F 2 "" H 3550 3100 50 0001 C CNN
F 3 "" H 3550 3100 50 0001 C CNN
1 3550 3100
1 0 0 -1
$EndComp
Wire Wire Line
10550 800 10550 950
Wire Wire Line
10900 800 10900 950
Wire Wire Line
7050 2650 7050 2700
Wire Wire Line
7050 2700 7050 2800
Wire Wire Line
7050 2700 6900 2700
Wire Wire Line
6900 3200 7050 3200
Wire Wire Line
7050 3100 7050 3200
Wire Wire Line
7050 3200 7050 3350
Wire Wire Line
3300 3100 3550 3100
Wire Wire Line
3300 3300 3550 3300
Wire Wire Line
4200 2900 3750 2900
Wire Wire Line
3750 2900 3750 2850
Wire Wire Line
3750 2850 3400 2850
Wire Wire Line
3400 2850 3400 2900
Wire Wire Line
3400 2900 3300 2900
Wire Wire Line
3300 2700 4200 2700
$Comp
L GND #PWR03
U 1 1 597F3601
P 4200 4400
F 0 "#PWR03" H 4200 4150 50 0001 C CNN
F 1 "GND" H 4205 4227 50 0000 C CNN
F 2 "" H 4200 4400 50 0001 C CNN
F 3 "" H 4200 4400 50 0001 C CNN
1 4200 4400
1 0 0 -1
$EndComp
$Comp
L GND #PWR05
U 1 1 597F3616
P 4900 4400
F 0 "#PWR05" H 4900 4150 50 0001 C CNN
F 1 "GND" H 4905 4227 50 0000 C CNN
F 2 "" H 4900 4400 50 0001 C CNN
F 3 "" H 4900 4400 50 0001 C CNN
1 4900 4400
1 0 0 -1
$EndComp
$Comp
L GND #PWR06
U 1 1 597F362B
P 5550 4400
F 0 "#PWR06" H 5550 4150 50 0001 C CNN
F 1 "GND" H 5555 4227 50 0000 C CNN
F 2 "" H 5550 4400 50 0001 C CNN
F 3 "" H 5550 4400 50 0001 C CNN
1 5550 4400
1 0 0 -1
$EndComp
Wire Wire Line
5550 4250 5550 4400
Wire Wire Line
4900 4250 4900 4400
Wire Wire Line
4200 4250 4200 4400
Wire Wire Line
4200 2800 3900 2800
Wire Wire Line
3900 2800 3900 3750
Wire Wire Line
3900 3750 3650 3750
Wire Wire Line
3650 3750 3650 4250
Wire Wire Line
3650 4250 3800 4250
Wire Wire Line
4200 3000 4000 3000
Wire Wire Line
4000 3000 4000 3750
Wire Wire Line
4000 3750 4350 3750
Wire Wire Line
4350 3750 4350 4250
Wire Wire Line
4350 4250 4500 4250
Wire Wire Line
4200 3100 4100 3100
Wire Wire Line
4100 3100 4100 3650
Wire Wire Line
4100 3650 5050 3650
Wire Wire Line
5050 3650 5050 4250
Wire Wire Line
5050 4250 5150 4250
$Comp
L +BATT #PWR04
U 1 1 597F3CFF
P 4800 3550
F 0 "#PWR04" H 4800 3400 50 0001 C CNN
F 1 "+BATT" V 4815 3678 50 0000 L CNN
F 2 "" H 4800 3550 50 0001 C CNN
F 3 "" H 4800 3550 50 0001 C CNN
1 4800 3550
0 1 1 0
$EndComp
$Comp
L R R1
U 1 1 597F3D75
P 4500 3550
F 0 "R1" V 4293 3550 50 0000 C CNN
F 1 "10k" V 4384 3550 50 0000 C CNN
F 2 "Resistors_SMD:R_0603_HandSoldering" V 4430 3550 50 0001 C CNN
F 3 "" H 4500 3550 50 0001 C CNN
1 4500 3550
0 1 1 0
$EndComp
Wire Wire Line
4800 3550 4650 3550
Wire Wire Line
4350 3550 4200 3550
Wire Wire Line
4200 3550 4200 3200
$Comp
L C C1
U 1 1 597F4561
P 7050 2950
F 0 "C1" H 7165 2996 50 0000 L CNN
F 1 "C" H 7165 2905 50 0000 L CNN
F 2 "Capacitors_ThroughHole:C_Disc_D3.0mm_W1.6mm_P2.50mm" H 7088 2800 50 0001 C CNN
F 3 "" H 7050 2950 50 0001 C CNN
1 7050 2950
1 0 0 -1
$EndComp
Connection ~ 7050 2700
Connection ~ 7050 3200
$Comp
L SW_Push SW1
U 1 1 597F567B
P 4000 4250
F 0 "SW1" H 4000 4535 50 0000 C CNN
F 1 "SW_Push" H 4000 4444 50 0000 C CNN
F 2 "Switch_SMD_5x5mm:Switch_SMD_5x5mm" H 4000 4450 50 0001 C CNN
F 3 "" H 4000 4450 50 0001 C CNN
1 4000 4250
1 0 0 -1
$EndComp
$Comp
L SW_Push SW2
U 1 1 597F574D
P 4700 4250
F 0 "SW2" H 4700 4535 50 0000 C CNN
F 1 "SW_Push" H 4700 4444 50 0000 C CNN
F 2 "Switch_SMD_5x5mm:Switch_SMD_5x5mm" H 4700 4450 50 0001 C CNN
F 3 "" H 4700 4450 50 0001 C CNN
1 4700 4250
1 0 0 -1
$EndComp
$Comp
L SW_Push SW3
U 1 1 597F5781
P 5350 4250
F 0 "SW3" H 5350 4535 50 0000 C CNN
F 1 "SW_Push" H 5350 4444 50 0000 C CNN
F 2 "Switch_SMD_5x5mm:Switch_SMD_5x5mm" H 5350 4450 50 0001 C CNN
F 3 "" H 5350 4450 50 0001 C CNN
1 5350 4250
1 0 0 -1
$EndComp
Text Label 3500 2850 0 60 ~ 0
SCK
Text Label 3500 2700 0 60 ~ 0
SDA
$EndSCHEMATC

View File

@ -0,0 +1,12 @@
(module Switch_SMD_5x5mm (layer F.Cu) (tedit 597F70C9)
(fp_text reference REF** (at 0 0.5) (layer F.SilkS)
(effects (font (size 1 1) (thickness 0.15)))
)
(fp_text value Switch_SMD_5x5mm (at 0 -0.5) (layer F.Fab)
(effects (font (size 1 1) (thickness 0.15)))
)
(pad 1 smd oval (at -4 -3) (size 1.524 0.5) (layers F.Cu F.Paste F.Mask))
(pad 1 smd oval (at 2.5 -3) (size 1.524 0.5) (layers F.Cu F.Paste F.Mask))
(pad 2 smd oval (at -4 -6.7) (size 1.524 0.5) (layers F.Cu F.Paste F.Mask))
(pad 2 smd oval (at 2.5 -6.7) (size 1.524 0.5) (layers F.Cu F.Paste F.Mask))
)

4
KiCad/fp-lib-table Normal file
View File

@ -0,0 +1,4 @@
(fp_lib_table
(lib (name Switch_SMD_5x5mm)(type KiCad)(uri "$(KIPRJMOD)/Switch_SMD_5x5mm.pretty")(options "")(descr ""))
(lib (name ATTiny85_HandSoldering)(type KiCad)(uri "$(KIPRJMOD)/ATTiny85_HandSoldering.pretty")(options "")(descr ""))
)

3
README.md Normal file
View File

@ -0,0 +1,3 @@
Schematics and PCB layout made using KiCad (http://kicad-pcb.org/).
ATTiny85's firmware is built using PlatformIO (http://platformio.org).

View File

@ -0,0 +1,22 @@
{
"folders":
[
{
"path": ".",
"file_exclude_patterns": ["*.sublime-project"]
}
]/*,
"build_systems":
[
{
"name": "PlatformIO - Build",
"cmd": ["platformio", "run"],
"working_dir": "$project_path"
},
{
"name": "PlatformIO - Upload",
"cmd": ["platformio", "run", "--target", "upload"],
"working_dir": "$project_path"
}
]*/
}

1
Source/build.ps1 Normal file
View File

@ -0,0 +1 @@
& platformio run

View File

@ -0,0 +1,19 @@
Copyright (c) 2016 Neven Boyanov, Tinusaur Team. All Rights Reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@ -0,0 +1,40 @@
SSD1306xLED - Drivers for SSD1306 controlled dot matrix OLED/PLED 128x64 displays
-----------------------------------------------------------------------------------
Copyright (c) 2016 Neven Boyanov, Tinusaur Team. All Rights Reserved.
Distributed as open source software under MIT License, see LICENSE.txt file.
Please, as a favor, retain the link http://tinusaur.org to The Tinusaur Project.
-----------------------------------------------------------------------------------
SSD1306xLED is a C library for working with the SSD1306 display driver to control dot matrix OLED/PLED 128x64 displays. It is intended to be used with the Tinusaur board but should also work with any other board based on ATtiny85 or similar microcontroller.
The SSD1306xLED library is written in plain C and does not require any additional libraries to function except those that come with the SDK.
This library has support for and tested work with the 8 MHz CPU clock mode.
Modules, folders and files Structure:
- ssd1306xled - the SSD1306xLED library
- font6x8.h - small 6x8 font
- font8x16.h - large 8x16 font
- ssd1306xled.c - library implementation
- ssd1306xled.h - library headers
- ssd1306xled8x16.c - large font 8x16 implementation
- ssd1306xled8x16.h - large font 8x16 headers
- ssd1306xled_cn - additional functions for handling some Chinese characters (currently does not work)
- ssd1306xled_test - simple testing program for the library
- img0_128x64c1.h - sample bitmap image 128x64
- img1_128x64c1.h - sample bitmap image 128x64
- main.c - sample code using the library
- ssd1306xled_test_cn - test for Chinese functions (currently does not work)
==== Links ====
Official Tinusaur Project website: http://tinusaur.org
Project SSD1306xLED page: http://tinusaur.org/projects/ssd1306xled/
Project SSD1306xLED source code: https://bitbucket.org/tinusaur/ssd1306xled
Twitter: https://twitter.com/tinusaur
Facebook: https://www.facebook.com/tinusaur

View File

@ -0,0 +1,119 @@
/**
* SSD1306xLED - Drivers for SSD1306 controlled dot matrix OLED/PLED 128x64 displays
*
* @created: 2014-08-12
* @author: Neven Boyanov
*
* This is part of the Tinusaur/SSD1306xLED project.
*
* Copyright (c) 2016 Neven Boyanov, Tinusaur Team. All Rights Reserved.
* Distributed as open source software under MIT License, see LICENSE.txt file.
* Please, as a favor, retain the link http://tinusaur.org to The Tinusaur Project.
*
* Source code available at: https://bitbucket.org/tinusaur/ssd1306xled
*
*/
// ============================================================================
#include <avr/pgmspace.h>
// ----------------------------------------------------------------------------
/* Standard ASCII 6x8 font */
const uint8_t ssd1306xled_font6x8 [] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // sp
0x00, 0x00, 0x00, 0x2f, 0x00, 0x00, // !
0x00, 0x00, 0x07, 0x00, 0x07, 0x00, // "
0x00, 0x14, 0x7f, 0x14, 0x7f, 0x14, // #
0x00, 0x24, 0x2a, 0x7f, 0x2a, 0x12, // $
0x00, 0x62, 0x64, 0x08, 0x13, 0x23, // %
0x00, 0x36, 0x49, 0x55, 0x22, 0x50, // &
0x00, 0x00, 0x05, 0x03, 0x00, 0x00, // '
0x00, 0x00, 0x1c, 0x22, 0x41, 0x00, // (
0x00, 0x00, 0x41, 0x22, 0x1c, 0x00, // )
0x00, 0x14, 0x08, 0x3E, 0x08, 0x14, // *
0x00, 0x08, 0x08, 0x3E, 0x08, 0x08, // +
0x00, 0x00, 0x00, 0xA0, 0x60, 0x00, // ,
0x00, 0x08, 0x08, 0x08, 0x08, 0x08, // -
0x00, 0x00, 0x60, 0x60, 0x00, 0x00, // .
0x00, 0x20, 0x10, 0x08, 0x04, 0x02, // /
0x00, 0x3E, 0x51, 0x49, 0x45, 0x3E, // 0
0x00, 0x00, 0x42, 0x7F, 0x40, 0x00, // 1
0x00, 0x42, 0x61, 0x51, 0x49, 0x46, // 2
0x00, 0x21, 0x41, 0x45, 0x4B, 0x31, // 3
0x00, 0x18, 0x14, 0x12, 0x7F, 0x10, // 4
0x00, 0x27, 0x45, 0x45, 0x45, 0x39, // 5
0x00, 0x3C, 0x4A, 0x49, 0x49, 0x30, // 6
0x00, 0x01, 0x71, 0x09, 0x05, 0x03, // 7
0x00, 0x36, 0x49, 0x49, 0x49, 0x36, // 8
0x00, 0x06, 0x49, 0x49, 0x29, 0x1E, // 9
0x00, 0x00, 0x36, 0x36, 0x00, 0x00, // :
0x00, 0x00, 0x56, 0x36, 0x00, 0x00, // ;
0x00, 0x08, 0x14, 0x22, 0x41, 0x00, // <
0x00, 0x14, 0x14, 0x14, 0x14, 0x14, // =
0x00, 0x00, 0x41, 0x22, 0x14, 0x08, // >
0x00, 0x02, 0x01, 0x51, 0x09, 0x06, // ?
0x00, 0x32, 0x49, 0x59, 0x51, 0x3E, // @
0x00, 0x7C, 0x12, 0x11, 0x12, 0x7C, // A
0x00, 0x7F, 0x49, 0x49, 0x49, 0x36, // B
0x00, 0x3E, 0x41, 0x41, 0x41, 0x22, // C
0x00, 0x7F, 0x41, 0x41, 0x22, 0x1C, // D
0x00, 0x7F, 0x49, 0x49, 0x49, 0x41, // E
0x00, 0x7F, 0x09, 0x09, 0x09, 0x01, // F
0x00, 0x3E, 0x41, 0x49, 0x49, 0x7A, // G
0x00, 0x7F, 0x08, 0x08, 0x08, 0x7F, // H
0x00, 0x00, 0x41, 0x7F, 0x41, 0x00, // I
0x00, 0x20, 0x40, 0x41, 0x3F, 0x01, // J
0x00, 0x7F, 0x08, 0x14, 0x22, 0x41, // K
0x00, 0x7F, 0x40, 0x40, 0x40, 0x40, // L
0x00, 0x7F, 0x02, 0x0C, 0x02, 0x7F, // M
0x00, 0x7F, 0x04, 0x08, 0x10, 0x7F, // N
0x00, 0x3E, 0x41, 0x41, 0x41, 0x3E, // O
0x00, 0x7F, 0x09, 0x09, 0x09, 0x06, // P
0x00, 0x3E, 0x41, 0x51, 0x21, 0x5E, // Q
0x00, 0x7F, 0x09, 0x19, 0x29, 0x46, // R
0x00, 0x46, 0x49, 0x49, 0x49, 0x31, // S
0x00, 0x01, 0x01, 0x7F, 0x01, 0x01, // T
0x00, 0x3F, 0x40, 0x40, 0x40, 0x3F, // U
0x00, 0x1F, 0x20, 0x40, 0x20, 0x1F, // V
0x00, 0x3F, 0x40, 0x38, 0x40, 0x3F, // W
0x00, 0x63, 0x14, 0x08, 0x14, 0x63, // X
0x00, 0x07, 0x08, 0x70, 0x08, 0x07, // Y
0x00, 0x61, 0x51, 0x49, 0x45, 0x43, // Z
0x00, 0x00, 0x7F, 0x41, 0x41, 0x00, // [
0x00, 0x55, 0x2A, 0x55, 0x2A, 0x55, // 55
0x00, 0x00, 0x41, 0x41, 0x7F, 0x00, // ]
0x00, 0x04, 0x02, 0x01, 0x02, 0x04, // ^
0x00, 0x40, 0x40, 0x40, 0x40, 0x40, // _
0x00, 0x00, 0x01, 0x02, 0x04, 0x00, // '
0x00, 0x20, 0x54, 0x54, 0x54, 0x78, // a
0x00, 0x7F, 0x48, 0x44, 0x44, 0x38, // b
0x00, 0x38, 0x44, 0x44, 0x44, 0x20, // c
0x00, 0x38, 0x44, 0x44, 0x48, 0x7F, // d
0x00, 0x38, 0x54, 0x54, 0x54, 0x18, // e
0x00, 0x08, 0x7E, 0x09, 0x01, 0x02, // f
0x00, 0x18, 0xA4, 0xA4, 0xA4, 0x7C, // g
0x00, 0x7F, 0x08, 0x04, 0x04, 0x78, // h
0x00, 0x00, 0x44, 0x7D, 0x40, 0x00, // i
0x00, 0x40, 0x80, 0x84, 0x7D, 0x00, // j
0x00, 0x7F, 0x10, 0x28, 0x44, 0x00, // k
0x00, 0x00, 0x41, 0x7F, 0x40, 0x00, // l
0x00, 0x7C, 0x04, 0x18, 0x04, 0x78, // m
0x00, 0x7C, 0x08, 0x04, 0x04, 0x78, // n
0x00, 0x38, 0x44, 0x44, 0x44, 0x38, // o
0x00, 0xFC, 0x24, 0x24, 0x24, 0x18, // p
0x00, 0x18, 0x24, 0x24, 0x18, 0xFC, // q
0x00, 0x7C, 0x08, 0x04, 0x04, 0x08, // r
0x00, 0x48, 0x54, 0x54, 0x54, 0x20, // s
0x00, 0x04, 0x3F, 0x44, 0x40, 0x20, // t
0x00, 0x3C, 0x40, 0x40, 0x20, 0x7C, // u
0x00, 0x1C, 0x20, 0x40, 0x20, 0x1C, // v
0x00, 0x3C, 0x40, 0x30, 0x40, 0x3C, // w
0x00, 0x44, 0x28, 0x10, 0x28, 0x44, // x
0x00, 0x1C, 0xA0, 0xA0, 0xA0, 0x7C, // y
0x00, 0x44, 0x64, 0x54, 0x4C, 0x44, // z
0x14, 0x14, 0x14, 0x14, 0x14, 0x14, // horiz lines
};
// ============================================================================

View File

@ -0,0 +1,122 @@
/**
* SSD1306xLED - Drivers for SSD1306 controlled dot matrix OLED/PLED 128x64 displays
*
* @created: 2014-08-12
* @author: Neven Boyanov
*
* This is part of the Tinusaur/SSD1306xLED project.
*
* Copyright (c) 2016 Neven Boyanov, Tinusaur Team. All Rights Reserved.
* Distributed as open source software under MIT License, see LICENSE.txt file.
* Please, as a favor, retain the link http://tinusaur.org to The Tinusaur Project.
*
* Source code available at: https://bitbucket.org/tinusaur/ssd1306xled
*
*/
// ============================================================================
#include <avr/pgmspace.h>
// ----------------------------------------------------------------------------
/* Standard ASCII 8x16 font */
const uint8_t ssd1306xled_font8x16 [] PROGMEM = {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // 0
0x00,0x00,0x00,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x33,0x30,0x00,0x00,0x00, // ! 1
0x00,0x10,0x0C,0x06,0x10,0x0C,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // " 2
0x40,0xC0,0x78,0x40,0xC0,0x78,0x40,0x00,0x04,0x3F,0x04,0x04,0x3F,0x04,0x04,0x00, // # 3
0x00,0x70,0x88,0xFC,0x08,0x30,0x00,0x00,0x00,0x18,0x20,0xFF,0x21,0x1E,0x00,0x00, // $ 4
0xF0,0x08,0xF0,0x00,0xE0,0x18,0x00,0x00,0x00,0x21,0x1C,0x03,0x1E,0x21,0x1E,0x00, // % 5
0x00,0xF0,0x08,0x88,0x70,0x00,0x00,0x00,0x1E,0x21,0x23,0x24,0x19,0x27,0x21,0x10, // & 6
0x10,0x16,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // ' 7
0x00,0x00,0x00,0xE0,0x18,0x04,0x02,0x00,0x00,0x00,0x00,0x07,0x18,0x20,0x40,0x00, // ( 8
0x00,0x02,0x04,0x18,0xE0,0x00,0x00,0x00,0x00,0x40,0x20,0x18,0x07,0x00,0x00,0x00, // ) 9
0x40,0x40,0x80,0xF0,0x80,0x40,0x40,0x00,0x02,0x02,0x01,0x0F,0x01,0x02,0x02,0x00, // * 10
0x00,0x00,0x00,0xF0,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x1F,0x01,0x01,0x01,0x00, // + 11
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xB0,0x70,0x00,0x00,0x00,0x00,0x00, // , 12
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01, // - 13
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,0x00,0x00, // . 14
0x00,0x00,0x00,0x00,0x80,0x60,0x18,0x04,0x00,0x60,0x18,0x06,0x01,0x00,0x00,0x00, // / 15
0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x0F,0x10,0x20,0x20,0x10,0x0F,0x00, // 0 16
0x00,0x10,0x10,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00, // 1 17
0x00,0x70,0x08,0x08,0x08,0x88,0x70,0x00,0x00,0x30,0x28,0x24,0x22,0x21,0x30,0x00, // 2 18
0x00,0x30,0x08,0x88,0x88,0x48,0x30,0x00,0x00,0x18,0x20,0x20,0x20,0x11,0x0E,0x00, // 3 19
0x00,0x00,0xC0,0x20,0x10,0xF8,0x00,0x00,0x00,0x07,0x04,0x24,0x24,0x3F,0x24,0x00, // 4 20
0x00,0xF8,0x08,0x88,0x88,0x08,0x08,0x00,0x00,0x19,0x21,0x20,0x20,0x11,0x0E,0x00, // 5 21
0x00,0xE0,0x10,0x88,0x88,0x18,0x00,0x00,0x00,0x0F,0x11,0x20,0x20,0x11,0x0E,0x00, // 6 22
0x00,0x38,0x08,0x08,0xC8,0x38,0x08,0x00,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x00, // 7 23
0x00,0x70,0x88,0x08,0x08,0x88,0x70,0x00,0x00,0x1C,0x22,0x21,0x21,0x22,0x1C,0x00, // 8 24
0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x00,0x31,0x22,0x22,0x11,0x0F,0x00, // 9 25
0x00,0x00,0x00,0xC0,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00, // : 26
0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x60,0x00,0x00,0x00,0x00, // ; 27
0x00,0x00,0x80,0x40,0x20,0x10,0x08,0x00,0x00,0x01,0x02,0x04,0x08,0x10,0x20,0x00, // < 28
0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x00,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x00, // = 29
0x00,0x08,0x10,0x20,0x40,0x80,0x00,0x00,0x00,0x20,0x10,0x08,0x04,0x02,0x01,0x00, // > 30
0x00,0x70,0x48,0x08,0x08,0x08,0xF0,0x00,0x00,0x00,0x00,0x30,0x36,0x01,0x00,0x00, // ? 31
0xC0,0x30,0xC8,0x28,0xE8,0x10,0xE0,0x00,0x07,0x18,0x27,0x24,0x23,0x14,0x0B,0x00, // @ 32
0x00,0x00,0xC0,0x38,0xE0,0x00,0x00,0x00,0x20,0x3C,0x23,0x02,0x02,0x27,0x38,0x20, // A 33
0x08,0xF8,0x88,0x88,0x88,0x70,0x00,0x00,0x20,0x3F,0x20,0x20,0x20,0x11,0x0E,0x00, // B 34
0xC0,0x30,0x08,0x08,0x08,0x08,0x38,0x00,0x07,0x18,0x20,0x20,0x20,0x10,0x08,0x00, // C 35
0x08,0xF8,0x08,0x08,0x08,0x10,0xE0,0x00,0x20,0x3F,0x20,0x20,0x20,0x10,0x0F,0x00, // D 36
0x08,0xF8,0x88,0x88,0xE8,0x08,0x10,0x00,0x20,0x3F,0x20,0x20,0x23,0x20,0x18,0x00, // E 37
0x08,0xF8,0x88,0x88,0xE8,0x08,0x10,0x00,0x20,0x3F,0x20,0x00,0x03,0x00,0x00,0x00, // F 38
0xC0,0x30,0x08,0x08,0x08,0x38,0x00,0x00,0x07,0x18,0x20,0x20,0x22,0x1E,0x02,0x00, // G 39
0x08,0xF8,0x08,0x00,0x00,0x08,0xF8,0x08,0x20,0x3F,0x21,0x01,0x01,0x21,0x3F,0x20, // H 40
0x00,0x08,0x08,0xF8,0x08,0x08,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00, // I 41
0x00,0x00,0x08,0x08,0xF8,0x08,0x08,0x00,0xC0,0x80,0x80,0x80,0x7F,0x00,0x00,0x00, // J 42
0x08,0xF8,0x88,0xC0,0x28,0x18,0x08,0x00,0x20,0x3F,0x20,0x01,0x26,0x38,0x20,0x00, // K 43
0x08,0xF8,0x08,0x00,0x00,0x00,0x00,0x00,0x20,0x3F,0x20,0x20,0x20,0x20,0x30,0x00, // L 44
0x08,0xF8,0xF8,0x00,0xF8,0xF8,0x08,0x00,0x20,0x3F,0x00,0x3F,0x00,0x3F,0x20,0x00, // M 45
0x08,0xF8,0x30,0xC0,0x00,0x08,0xF8,0x08,0x20,0x3F,0x20,0x00,0x07,0x18,0x3F,0x00, // N 46
0xE0,0x10,0x08,0x08,0x08,0x10,0xE0,0x00,0x0F,0x10,0x20,0x20,0x20,0x10,0x0F,0x00, // O 47
0x08,0xF8,0x08,0x08,0x08,0x08,0xF0,0x00,0x20,0x3F,0x21,0x01,0x01,0x01,0x00,0x00, // P 48
0xE0,0x10,0x08,0x08,0x08,0x10,0xE0,0x00,0x0F,0x18,0x24,0x24,0x38,0x50,0x4F,0x00, // Q 49
0x08,0xF8,0x88,0x88,0x88,0x88,0x70,0x00,0x20,0x3F,0x20,0x00,0x03,0x0C,0x30,0x20, // R 50
0x00,0x70,0x88,0x08,0x08,0x08,0x38,0x00,0x00,0x38,0x20,0x21,0x21,0x22,0x1C,0x00, // S 51
0x18,0x08,0x08,0xF8,0x08,0x08,0x18,0x00,0x00,0x00,0x20,0x3F,0x20,0x00,0x00,0x00, // T 52
0x08,0xF8,0x08,0x00,0x00,0x08,0xF8,0x08,0x00,0x1F,0x20,0x20,0x20,0x20,0x1F,0x00, // U 53
0x08,0x78,0x88,0x00,0x00,0xC8,0x38,0x08,0x00,0x00,0x07,0x38,0x0E,0x01,0x00,0x00, // V 54
0xF8,0x08,0x00,0xF8,0x00,0x08,0xF8,0x00,0x03,0x3C,0x07,0x00,0x07,0x3C,0x03,0x00, // W 55
0x08,0x18,0x68,0x80,0x80,0x68,0x18,0x08,0x20,0x30,0x2C,0x03,0x03,0x2C,0x30,0x20, // X 56
0x08,0x38,0xC8,0x00,0xC8,0x38,0x08,0x00,0x00,0x00,0x20,0x3F,0x20,0x00,0x00,0x00, // Y 57
0x10,0x08,0x08,0x08,0xC8,0x38,0x08,0x00,0x20,0x38,0x26,0x21,0x20,0x20,0x18,0x00, // Z 58
0x00,0x00,0x00,0xFE,0x02,0x02,0x02,0x00,0x00,0x00,0x00,0x7F,0x40,0x40,0x40,0x00, // [ 59
0x00,0x0C,0x30,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x06,0x38,0xC0,0x00, // \ 60
0x00,0x02,0x02,0x02,0xFE,0x00,0x00,0x00,0x00,0x40,0x40,0x40,0x7F,0x00,0x00,0x00, // ] 61
0x00,0x00,0x04,0x02,0x02,0x02,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // ^ 62
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80, // _ 63
0x00,0x02,0x02,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // ` 64
0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x19,0x24,0x22,0x22,0x22,0x3F,0x20, // a 65
0x08,0xF8,0x00,0x80,0x80,0x00,0x00,0x00,0x00,0x3F,0x11,0x20,0x20,0x11,0x0E,0x00, // b 66
0x00,0x00,0x00,0x80,0x80,0x80,0x00,0x00,0x00,0x0E,0x11,0x20,0x20,0x20,0x11,0x00, // c 67
0x00,0x00,0x00,0x80,0x80,0x88,0xF8,0x00,0x00,0x0E,0x11,0x20,0x20,0x10,0x3F,0x20, // d 68
0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x1F,0x22,0x22,0x22,0x22,0x13,0x00, // e 69
0x00,0x80,0x80,0xF0,0x88,0x88,0x88,0x18,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00, // f 70
0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x6B,0x94,0x94,0x94,0x93,0x60,0x00, // g 71
0x08,0xF8,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x3F,0x21,0x00,0x00,0x20,0x3F,0x20, // h 72
0x00,0x80,0x98,0x98,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00, // i 73
0x00,0x00,0x00,0x80,0x98,0x98,0x00,0x00,0x00,0xC0,0x80,0x80,0x80,0x7F,0x00,0x00, // j 74
0x08,0xF8,0x00,0x00,0x80,0x80,0x80,0x00,0x20,0x3F,0x24,0x02,0x2D,0x30,0x20,0x00, // k 75
0x00,0x08,0x08,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00, // l 76
0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x20,0x3F,0x20,0x00,0x3F,0x20,0x00,0x3F, // m 77
0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x3F,0x21,0x00,0x00,0x20,0x3F,0x20, // n 78
0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x1F,0x20,0x20,0x20,0x20,0x1F,0x00, // o 79
0x80,0x80,0x00,0x80,0x80,0x00,0x00,0x00,0x80,0xFF,0xA1,0x20,0x20,0x11,0x0E,0x00, // p 80
0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x0E,0x11,0x20,0x20,0xA0,0xFF,0x80, // q 81
0x80,0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x20,0x20,0x3F,0x21,0x20,0x00,0x01,0x00, // r 82
0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x33,0x24,0x24,0x24,0x24,0x19,0x00, // s 83
0x00,0x80,0x80,0xE0,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x1F,0x20,0x20,0x00,0x00, // t 84
0x80,0x80,0x00,0x00,0x00,0x80,0x80,0x00,0x00,0x1F,0x20,0x20,0x20,0x10,0x3F,0x20, // u 85
0x80,0x80,0x80,0x00,0x00,0x80,0x80,0x80,0x00,0x01,0x0E,0x30,0x08,0x06,0x01,0x00, // v 86
0x80,0x80,0x00,0x80,0x00,0x80,0x80,0x80,0x0F,0x30,0x0C,0x03,0x0C,0x30,0x0F,0x00, // w 87
0x00,0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x31,0x2E,0x0E,0x31,0x20,0x00, // x 88
0x80,0x80,0x80,0x00,0x00,0x80,0x80,0x80,0x80,0x81,0x8E,0x70,0x18,0x06,0x01,0x00, // y 89
0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x21,0x30,0x2C,0x22,0x21,0x30,0x00, // z 90
0x00,0x00,0x00,0x00,0x80,0x7C,0x02,0x02,0x00,0x00,0x00,0x00,0x00,0x3F,0x40,0x40, // { 91
0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00, // | 92
0x00,0x02,0x02,0x7C,0x80,0x00,0x00,0x00,0x00,0x40,0x40,0x3F,0x00,0x00,0x00,0x00, // } 93
0x00,0x06,0x01,0x01,0x02,0x02,0x04,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // ~ 94
};
// ============================================================================

View File

@ -0,0 +1,114 @@
/**
* NUM2STR - Functions to handle the conversion of numeric vales to strings.
*
* @created 2014-12-18
* @author Neven Boyanov
* @version 2016-04-17 (last modified)
*
* This is part of the Tinusaur/TinyAVRLib project.
*
* Copyright (c) 2016 Neven Boyanov, Tinusaur Team. All Rights Reserved.
* Distributed as open source software under MIT License, see LICENSE.txt file.
* Please, as a favor, retain the link http://tinusaur.org to The Tinusaur Project.
*
* Source code available at: https://bitbucket.org/tinusaur/tinyavrlib
*
*/
// ============================================================================
#include "num2str.h"
// ----------------------------------------------------------------------------
// NOTE: This implementation is borrowed from the LCDDDD library.
// Original source code at: https://bitbucket.org/boyanov/avr/src/default/lcdddd/src/lcdddd/lcdddd.h
uint8_t usint2decascii(uint16_t num, char *buffer)
{
const unsigned short powers[] = { 10000u, 1000u, 100u, 10u, 1u }; // The "const unsigned short" combination gives shortest code.
char digit; // "digit" is stored in a char array, so it should be of type char.
uint8_t digits = USINT2DECASCII_MAX_DIGITS - 1;
for (uint8_t pos = 0; pos < 5; pos++) // "pos" is index in array, so should be of type int.
{
digit = 0;
while (num >= powers[pos])
{
digit++;
num -= powers[pos];
}
// ---- CHOOSE (1), (2) or (3) ----
// CHOICE (1) Fixed width, zero padded result.
/*
buffer[pos] = digit + '0'; // Convert to ASCII
*/
// CHOICE (2) Fixed width, zero padded result, digits offset.
/*
buffer[pos] = digit + '0'; // Convert to ASCII
// Note: Determines the offset of the first significant digit.
if (digits == -1 && digit != 0) digits = pos;
// Note: Could be used for variable width, not padded, left aligned result.
*/
// CHOICE (3) Fixed width, space (or anything else) padded result, digits offset.
// Note: Determines the offset of the first significant digit.
// Note: Could be used for variable width, not padded, left aligned result.
if (digits == USINT2DECASCII_MAX_DIGITS - 1)
{
if (digit == 0)
{
if (pos < USINT2DECASCII_MAX_DIGITS - 1) // Check position, so single "0" will be handled properly.
digit = -16; // Use: "-16" for space (' '), "-3" for dash/minus ('-'), "0" for zero ('0'), etc. ...
}
else
{
digits = pos;
}
}
buffer[pos] = digit + '0'; // Convert to ASCII
}
// NOTE: The resulting ascii text should not be terminated with '\0' here.
// The provided buffer maybe part of a larger text in both directions.
return digits;
}
// ----------------------------------------------------------------------------
// NOTE: The buffer should be always at least MAX_DIGITS in length - the function works with 16-bit numbers.
uint8_t usint2binascii(uint16_t num, char *buffer) {
uint16_t power = 0x8000; // This is the 1000 0000 0000 0000 binary number.
char digit; // "digit" is stored in a char array, so it should be of type char.
uint8_t digits = USINT2BINASCII_MAX_DIGITS - 1;
for (uint8_t pos = 0; pos < USINT2BINASCII_MAX_DIGITS; pos++) { // "pos" is index in an array.
digit = 0;
if (num >= power) {
digit++;
num -= power;
}
// Fixed width, space ('0', or anything else) padded result, digits offset.
// Note: Determines the offset of the first significant digit.
// Note: Could be used for variable width, not padded, left aligned result.
if (digits == USINT2BINASCII_MAX_DIGITS - 1) {
if (digit == 0) {
if (pos < USINT2BINASCII_MAX_DIGITS - 1) // Check position, so single "0" will be handled properly.
digit = 0; // Use: "-16" for space (' '), "-3" for dash/minus ('-'), "0" for zero ('0'), etc.
} else {
digits = pos;
}
}
buffer[pos] = digit + '0'; // Convert to ASCII
power = power >> 1;
}
// NOTE: The resulting ascii text should not be terminated with '\0' here.
// The provided buffer maybe part of a larger text in both directions.
return digits;
}
// ============================================================================

View File

@ -0,0 +1,41 @@
/**
* NUM2STR - Functions to handle the conversion of numeric vales to strings.
*
* @created 2014-12-18
* @author Neven Boyanov
* @version 2016-04-17 (last modified)
*
* This is part of the Tinusaur/TinyAVRLib project.
*
* Copyright (c) 2016 Neven Boyanov, Tinusaur Team. All Rights Reserved.
* Distributed as open source software under MIT License, see LICENSE.txt file.
* Please, as a favor, retain the link http://tinusaur.org to The Tinusaur Project.
*
* Source code available at: https://bitbucket.org/tinusaur/tinyavrlib
*
*/
// ============================================================================
#ifndef NUM2STR_H
#define NUM2STR_H
// ----------------------------------------------------------------------------
#include <stdint.h>
// ----------------------------------------------------------------------------
#define USINT2DECASCII_MAX_DIGITS 5
#define USINT2BINASCII_MAX_DIGITS 16
// ----------------------------------------------------------------------------
uint8_t usint2decascii(uint16_t, char *);
uint8_t usint2binascii(uint16_t, char *);
// ----------------------------------------------------------------------------
#endif
// ============================================================================

View File

@ -0,0 +1,237 @@
/**
* SSD1306xLED - Drivers for SSD1306 controlled dot matrix OLED/PLED 128x64 displays
*
* @created: 2014-08-12
* @author: Neven Boyanov
*
* This is part of the Tinusaur/SSD1306xLED project.
*
* Copyright (c) 2016 Neven Boyanov, Tinusaur Team. All Rights Reserved.
* Distributed as open source software under MIT License, see LICENSE.txt file.
* Please, as a favor, retain the link http://tinusaur.org to The Tinusaur Project.
*
* Source code available at: https://bitbucket.org/tinusaur/ssd1306xled
*
*/
// ============================================================================
#include <stdlib.h>
#include <avr/io.h>
#include <avr/pgmspace.h>
#include "ssd1306xled.h"
#include "font6x8.h"
#include "num2str.h"
// ----------------------------------------------------------------------------
// Convenience definitions for PORTB
#define DIGITAL_WRITE_HIGH(PORT) PORTB |= (1 << PORT)
#define DIGITAL_WRITE_LOW(PORT) PORTB &= ~(1 << PORT)
// ----------------------------------------------------------------------------
// Some code based on "IIC_wtihout_ACK" by http://www.14blog.com/archives/1358
const uint8_t ssd1306_init_sequence [] PROGMEM = { // Initialization Sequence
0xAE, // Display OFF (sleep mode)
0x20, 0b00, // Set Memory Addressing Mode
// 00=Horizontal Addressing Mode; 01=Vertical Addressing Mode;
// 10=Page Addressing Mode (RESET); 11=Invalid
0xB0, // Set Page Start Address for Page Addressing Mode, 0-7
0xC8, // Set COM Output Scan Direction
0x00, // ---set low column address
0x10, // ---set high column address
0x40, // --set start line address
0x81, 0x3F, // Set contrast control register
0xA1, // Set Segment Re-map. A0=address mapped; A1=address 127 mapped.
0xA6, // Set display mode. A6=Normal; A7=Inverse
0xA8, 0x3F, // Set multiplex ratio(1 to 64)
0xA4, // Output RAM to Display
// 0xA4=Output follows RAM content; 0xA5,Output ignores RAM content
0xD3, 0x00, // Set display offset. 00 = no offset
0xD5, // --set display clock divide ratio/oscillator frequency
0xF0, // --set divide ratio
0xD9, 0x22, // Set pre-charge period
0xDA, 0x12, // Set com pins hardware configuration
0xDB, // --set vcomh
0x20, // 0x20,0.77xVcc
0x8D, 0x14, // Set DC-DC enable
0xAF // Display ON in normal mode
};
// ----------------------------------------------------------------------------
// These function should become separate library for handling I2C simplified output.
void ssd1306_xfer_start(void)
{
DIGITAL_WRITE_HIGH(SSD1306_SCL); // Set to HIGH
DIGITAL_WRITE_HIGH(SSD1306_SDA); // Set to HIGH
DIGITAL_WRITE_LOW(SSD1306_SDA); // Set to LOW
DIGITAL_WRITE_LOW(SSD1306_SCL); // Set to LOW
}
void ssd1306_xfer_stop(void)
{
DIGITAL_WRITE_LOW(SSD1306_SCL); // Set to LOW
DIGITAL_WRITE_LOW(SSD1306_SDA); // Set to LOW
DIGITAL_WRITE_HIGH(SSD1306_SCL); // Set to HIGH
DIGITAL_WRITE_HIGH(SSD1306_SDA); // Set to HIGH
}
void ssd1306_send_byte(uint8_t byte)
{
uint8_t i;
for (i = 0; i < 8; i++)
{
if ((byte << i) & 0x80)
DIGITAL_WRITE_HIGH(SSD1306_SDA);
else
DIGITAL_WRITE_LOW(SSD1306_SDA);
DIGITAL_WRITE_HIGH(SSD1306_SCL);
DIGITAL_WRITE_LOW(SSD1306_SCL);
}
DIGITAL_WRITE_HIGH(SSD1306_SDA);
DIGITAL_WRITE_HIGH(SSD1306_SCL);
DIGITAL_WRITE_LOW(SSD1306_SCL);
}
void ssd1306_send_command_start(void) {
ssd1306_xfer_start();
ssd1306_send_byte(SSD1306_SA); // Slave address, SA0=0
ssd1306_send_byte(0x00); // write command
}
void ssd1306_send_command_stop(void) {
ssd1306_xfer_stop();
}
void ssd1306_send_command(uint8_t command)
{
ssd1306_send_command_start();
ssd1306_send_byte(command);
ssd1306_send_command_stop();
}
void ssd1306_send_data_start(void)
{
ssd1306_xfer_start();
ssd1306_send_byte(SSD1306_SA);
ssd1306_send_byte(0x40); //write data
}
void ssd1306_send_data_stop(void)
{
ssd1306_xfer_stop();
}
/*
void ssd1306_send_data(uint8_t byte)
{
ssd1306_send_data_start();
ssd1306_send_byte(byte);
ssd1306_send_data_stop();
}
*/
// ----------------------------------------------------------------------------
void ssd1306_init(void)
{
DDRB |= (1 << SSD1306_SDA); // Set port as output
DDRB |= (1 << SSD1306_SCL); // Set port as output
for (uint8_t i = 0; i < sizeof (ssd1306_init_sequence); i++) {
ssd1306_send_command(pgm_read_byte(&ssd1306_init_sequence[i]));
}
}
void ssd1306_setpos(uint8_t x, uint8_t y)
{
ssd1306_send_command_start();
ssd1306_send_byte(0xb0 + y);
ssd1306_send_byte(((x & 0xf0) >> 4) | 0x10); // | 0x10
/* TODO: Verify correctness */ ssd1306_send_byte((x & 0x0f)); // | 0x01
ssd1306_send_command_stop();
}
void ssd1306_fill4(uint8_t p1, uint8_t p2, uint8_t p3, uint8_t p4) {
ssd1306_setpos(0, 0);
ssd1306_send_data_start();
for (uint16_t i = 0; i < 128 * 8 / 4; i++) {
ssd1306_send_byte(p1);
ssd1306_send_byte(p2);
ssd1306_send_byte(p3);
ssd1306_send_byte(p4);
}
ssd1306_send_data_stop();
}
void ssd1306_fill2(uint8_t p1, uint8_t p2) {
ssd1306_fill4(p1, p2, p1, p2);
}
void ssd1306_fill(uint8_t p) {
ssd1306_fill4(p, p, p, p);
}
// ----------------------------------------------------------------------------
void ssd1306_char_font6x8(char ch) {
uint8_t c = ch - 32;
ssd1306_send_data_start();
for (uint8_t i = 0; i < 6; i++)
{
ssd1306_send_byte(pgm_read_byte(&ssd1306xled_font6x8[c * 6 + i]));
}
ssd1306_send_data_stop();
}
void ssd1306_string_font6x8(char *s) {
while (*s) {
ssd1306_char_font6x8(*s++);
}
}
char ssd1306_numdec_buffer[USINT2DECASCII_MAX_DIGITS + 1];
void ssd1306_numdec_font6x8(uint16_t num) {
ssd1306_numdec_buffer[USINT2DECASCII_MAX_DIGITS] = '\0'; // Terminate the string.
uint8_t digits = usint2decascii(num, ssd1306_numdec_buffer);
ssd1306_string_font6x8(ssd1306_numdec_buffer + digits);
}
void ssd1306_numdecp_font6x8(uint16_t num) {
ssd1306_numdec_buffer[USINT2DECASCII_MAX_DIGITS] = '\0'; // Terminate the string.
usint2decascii(num, ssd1306_numdec_buffer);
ssd1306_string_font6x8(ssd1306_numdec_buffer);
}
// ----------------------------------------------------------------------------
void ssd1306_draw_bmp(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1, const uint8_t bitmap[])
{
uint16_t j = 0;
uint8_t y;
if (y1 % 8 == 0) y = y1 / 8;
else y = y1 / 8 + 1;
for (y = y0; y < y1; y++)
{
ssd1306_setpos(x0,y);
ssd1306_send_data_start();
for (uint8_t x = x0; x < x1; x++)
{
ssd1306_send_byte(pgm_read_byte(&bitmap[j++]));
}
ssd1306_send_data_stop();
}
}
// ============================================================================

View File

@ -0,0 +1,69 @@
/**
* SSD1306xLED - Drivers for SSD1306 controlled dot matrix OLED/PLED 128x64 displays
*
* @created: 2014-08-12
* @author: Neven Boyanov
*
* This is part of the Tinusaur/SSD1306xLED project.
*
* Copyright (c) 2016 Neven Boyanov, Tinusaur Team. All Rights Reserved.
* Distributed as open source software under MIT License, see LICENSE.txt file.
* Please, as a favor, retain the link http://tinusaur.org to The Tinusaur Project.
*
* Source code available at: https://bitbucket.org/tinusaur/ssd1306xled
*
*/
#ifndef SSD1306XLED_H
#define SSD1306XLED_H
// ============================================================================
// -----(+)---------------> // Vcc, Pin 1 on SSD1306 Board
// -----(-)---------------> // GND, Pin 2 on SSD1306 Board
#ifndef SSD1306_SCL
#define SSD1306_SCL PB2 // SCL, Pin 3 on SSD1306 Board
#endif
#ifndef SSD1306_SDA
#define SSD1306_SDA PB0 // SDA, Pin 4 on SSD1306 Board
#endif
#ifndef SSD1306_SA
#define SSD1306_SA 0x78 // Slave address
#endif
// ----------------------------------------------------------------------------
// These functions are used only internally by the library
void ssd1306_xfer_start(void);
void ssd1306_xfer_stop(void);
void ssd1306_send_byte(uint8_t byte);
void ssd1306_send_command(uint8_t command);
void ssd1306_send_data_start(void);
void ssd1306_send_data_stop(void);
// ----------------------------------------------------------------------------
#define ssd1306_clear() ssd1306_fill(0);
#define ssd1306_char(c) ssd1306_char_font6x8(c)
#define ssd1306_string(s) ssd1306_string_font6x8(s)
#define ssd1306_numdec(n) ssd1306_numdec_font6x8(n)
#define ssd1306_numdecp(n) ssd1306_numdecp_font6x8(n)
// ----------------------------------------------------------------------------
void ssd1306_init(void);
void ssd1306_setpos(uint8_t x, uint8_t y);
void ssd1306_fill4(uint8_t, uint8_t, uint8_t, uint8_t);
void ssd1306_fill2(uint8_t p1, uint8_t p2);
void ssd1306_fill(uint8_t p);
void ssd1306_fillscreen(uint8_t fill);
void ssd1306_char_font6x8(char ch);
void ssd1306_string_font6x8(char *s);
void ssd1306_numdec_font6x8(uint16_t num);
void ssd1306_numdecp_font6x8(uint16_t num);
void ssd1306_draw_bmp(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1, const uint8_t bitmap[]);
// ============================================================================
#endif

View File

@ -0,0 +1,78 @@
/**
* SSD1306xLED - Drivers for SSD1306 controlled dot matrix OLED/PLED 128x64 displays
*
* @created: 2014-08-12
* @author: Neven Boyanov
*
* This is part of the Tinusaur/SSD1306xLED project.
*
* Copyright (c) 2016 Neven Boyanov, Tinusaur Team. All Rights Reserved.
* Distributed as open source software under MIT License, see LICENSE.txt file.
* Please, as a favor, retain the link http://tinusaur.org to The Tinusaur Project.
*
* Source code available at: https://bitbucket.org/tinusaur/ssd1306xled
*
*/
// ============================================================================
#include <stdlib.h>
#include <avr/io.h>
#include <avr/pgmspace.h>
#include "ssd1306xled.h"
#include "ssd1306xled8x16.h"
#include "font8x16.h"
// ----------------------------------------------------------------------------
/*
// NOTE: DOES NOT WORK
void ssd1306_char_font8x16(char ch) {
uint8_t c = ch - 32;
ssd1306_send_data_start();
for (uint8_t i = 0; i < 8; i++)
{
ssd1306_send_byte(pgm_read_byte(&ssd1306xled_font8x16[c * 16 + i]));
ssd1306_send_byte(pgm_read_byte(&ssd1306xled_font8x16[c * 16 + i + 8]));
}
ssd1306_send_data_stop();
}
// NOTE: DOES NOT WORK
void ssd1306_string_font8x16(char *s) {
while (*s) {
ssd1306_char_font8x16(*s++);
}
}
*/
void ssd1306_string_font8x16xy(uint8_t x, uint8_t y, const char s[]) {
uint8_t ch, j = 0;
while (s[j] != '\0') {
ch = s[j] - 32;
if (x > 120) {
x = 0;
y++;
}
ssd1306_setpos(x, y);
ssd1306_send_data_start();
for (uint8_t i = 0; i < 8; i++) {
ssd1306_send_byte(pgm_read_byte(&ssd1306xled_font8x16[ch * 16 + i]));
}
ssd1306_send_data_stop();
ssd1306_setpos(x, y + 1);
ssd1306_send_data_start();
for (uint8_t i = 0; i < 8; i++) {
ssd1306_send_byte(pgm_read_byte(&ssd1306xled_font8x16[ch * 16 + i + 8]));
}
ssd1306_send_data_stop();
x += 8;
j++;
}
}
// ============================================================================

View File

@ -0,0 +1,26 @@
/**
* SSD1306xLED - Drivers for SSD1306 controlled dot matrix OLED/PLED 128x64 displays
*
* @created: 2014-08-12
* @author: Neven Boyanov
*
* This is part of the Tinusaur/SSD1306xLED project.
*
* Copyright (c) 2016 Neven Boyanov, Tinusaur Team. All Rights Reserved.
* Distributed as open source software under MIT License, see LICENSE.txt file.
* Please, as a favor, retain the link http://tinusaur.org to The Tinusaur Project.
*
* Source code available at: https://bitbucket.org/tinusaur/ssd1306xled
*
*/
#ifndef SSD1306XLED8X16_H
#define SSD1306XLED8X16_H
// ============================================================================
void ssd1306_string_font8x16xy(uint8_t x, uint8_t y, const char ch[]);
// ============================================================================
#endif

19
Source/platformio.ini Normal file
View File

@ -0,0 +1,19 @@
; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; http://docs.platformio.org/page/projectconf.html
[env:attiny85]
platform = atmelavr
board = attiny85
upload_protocol = stk500v1
upload_flags = -P$UPLOAD_PORT -b$UPLOAD_SPEED
board_f_cpu = 8000000L
upload_port = COM7
upload_speed = 19200

BIN
Source/res/digits.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

BIN
Source/res/digits.psd Normal file

Binary file not shown.

148
Source/res/digits2code.py Normal file
View File

@ -0,0 +1,148 @@
# Converts digits.png to C code
#
# Image requirements:
# White pixels are considered "lit" on the OLED, black not. Height must be a
# multiple of 8.
#
# Each digit is assumed to be connected and needs to be separated by at least one vertical
# white line. The maximum character width is used for all characters. AAll characters are
# center-aligned to the maximum width.
#
# The output is arranged left-to-right, top-to-bottom, where each byte represents a column
# of 8 pixels. This corresponds to the page addressing mode used by the SSD1306xled library.
#
# Library requirements:
# Pillow (pip install pillow)
#
from __future__ import print_function
from PIL import Image
import math
InputFile = "digits.png"
OutputFile = "..\src\digits.h"
# Open image and convert to black and white
image = Image.open(InputFile).convert("L")
width, height = image.size
if height % 8 != 0:
print("Error: height must be a multiple of 8")
exit(1)
pixels = image.load()
def isEmptyColumn(x):
for y in range(height):
if pixels[x, y] != 0:
return False
return True
def getColumnValue(x, y):
value = 0
for yPos in range(8):
if pixels[x, y + yPos] != 0:
value = value | (1<<yPos)
return value
digits = []
maxWidth = 0
# Scan for start and end positions
x = 0
while x < width:
# Skip empty lines at the start
while x < width and isEmptyColumn(x):
x += 1
if x >= width:
break
startX = x
while x < width and not isEmptyColumn(x):
x += 1
digitWidth = x - startX
if digitWidth > maxWidth:
maxWidth = digitWidth
digits.append({ "start": startX, "stop": x, "width": digitWidth })
x += 1
if len(digits) != 10:
print("Error: expected 10 digits, found", len(digits))
exit(2)
rows = int(math.ceil(height / 8))
print("Found 10 digits")
print(" character width :", maxWidth)
print(" rows per character :", rows)
print(" total bytes :", rows * maxWidth * 10)
output = open(OutputFile, "w")
output.write("#ifndef __Digits\n")
output.write("#define __Digits\n")
output.write("\n")
output.write("#include <avr/pgmspace.h>\n")
output.write("\n")
output.write("#define DigitWidth " + str(maxWidth) + "\n")
output.write("#define DigitHeight " + str(height) + "\n")
output.write("#define DigitRows " + str(rows) + "\n")
output.write("#define DigitBytesPerChar " + str(rows * maxWidth) + "\n")
output.write("\n\n\n")
output.write("const uint8_t Digits[] PROGMEM = {\n")
def outputColumn(value, isLast):
output.write("0x{:02x}".format(value))
if not isLast:
output.write(", ")
# Generate byte array for each digit
for digitIndex in range(len(digits)):
digit = digits[digitIndex]
output.write(" // " + str(digitIndex) + "\n")
paddingLeft = int(math.floor((maxWidth - digit["width"]) / 2))
paddingRight = maxWidth - digit["width"] - paddingLeft
for rowIndex in range(rows):
lastRow = digitIndex == len(digits) - 1 and rowIndex == rows - 1
output.write(" ")
# Add padding to center align the character
for paddingIndex in range(paddingLeft):
outputColumn(0, False)
# Output one column at a time
for x in range(digit["start"], digit["stop"]):
outputColumn(getColumnValue(x, rowIndex * 8), lastRow and paddingRight == 0 and x == digit["stop"] - 1)
for paddingIndex in range(paddingRight):
outputColumn(0, lastRow and paddingIndex == paddingRight - 1)
output.write("\n")
output.write("\n")
output.write("};\n")
output.write("\n")
output.write("#endif\n")
output.close()
print("")
print("Wrote output to", OutputFile)

116
Source/src/digits.h Normal file
View File

@ -0,0 +1,116 @@
#ifndef __Digits
#define __Digits
#include <avr/pgmspace.h>
#define DigitWidth 41
#define DigitHeight 64
#define DigitRows 8
#define DigitBytesPerChar 328
const uint8_t Digits[] PROGMEM = {
// 0
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfc, 0xfe, 0xfe, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xfe, 0xfe, 0xfc, 0xfc, 0xf8, 0xf0, 0xe0, 0xc0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x80, 0xf0, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x0f, 0x07, 0x07, 0x03, 0x03, 0x03, 0x03, 0x03, 0x07, 0x07, 0x1f, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xfc, 0xf0, 0x80, 0x00, 0x00, 0x00,
0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x00, 0x00,
0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00,
0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00,
0x00, 0x00, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0xc0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xc0, 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, 0x00,
0x00, 0x00, 0x00, 0x01, 0x0f, 0x3f, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xfe, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfe, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x3f, 0x0f, 0x01, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x3f, 0x7f, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x7f, 0x3f, 0x3f, 0x1f, 0x0f, 0x07, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
// 1
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfc, 0xfe, 0xfe, 0xfe, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x03, 0x07, 0x0f, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
// 2
0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xf8, 0xfc, 0xfc, 0xfe, 0xfe, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xfe, 0xfe, 0xfc, 0xfc, 0xf8, 0xf8, 0xf0, 0xe0, 0xc0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x10, 0x7e, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x3f, 0x1f, 0x0f, 0x07, 0x07, 0x03, 0x03, 0x03, 0x03, 0x03, 0x07, 0x0f, 0x0f, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xf0, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x01, 0x07, 0x0f, 0x3f, 0x1f, 0x0f, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x3f, 0x1f, 0x0f, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x7f, 0x3f, 0x1f, 0x0f, 0x07, 0x03, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x80, 0xe0, 0xf8, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x1f, 0x0f, 0x07, 0x07, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xfc, 0xf8, 0xe0, 0x00, 0x00, 0x00,
0x00, 0x80, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0xf8, 0xf8, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xfc, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00,
0x00, 0x3f, 0x7f, 0xff, 0xff, 0xff, 0x7f, 0x7f, 0x7f, 0x7f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x7f, 0x3f, 0x3f, 0x1f, 0x0f, 0x07, 0x01, 0x00, 0x00, 0x00,
// 3
0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x7c, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x3f, 0x1f, 0x1f, 0x1f, 0x0f, 0x0f, 0x0f, 0x0f, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x87, 0xe7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x1f, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x3f, 0x0f, 0x07, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x78, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0xfc, 0xf8, 0xf8, 0xf0, 0xf0, 0xe0, 0xc0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x03, 0x07, 0x07, 0x1f, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xf8, 0xc0, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xe0, 0xe0, 0xc0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00,
0x00, 0x00, 0x80, 0xe0, 0xf0, 0xfc, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xfe, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfe, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x1f, 0x07, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x1f, 0x3f, 0x3f, 0x7f, 0x7f, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x7f, 0x7f, 0x3f, 0x3f, 0x1f, 0x1f, 0x0f, 0x07, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
// 4
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfc, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x7e, 0x3e, 0x1e, 0x0e, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xe0, 0xf0, 0xfc, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x3f, 0x0f, 0x07, 0x03, 0x01, 0x00, 0x00, 0x80, 0xc0, 0xc0, 0xe0, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xe0, 0xf8, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x1f, 0x0f, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x80, 0xe0, 0xf8, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xc0, 0xf8, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x0f, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf8, 0xf8, 0xf8, 0xfc, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc,
0x0f, 0x3f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x3f, 0x3f, 0x3f, 0x3f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x3f, 0x3f,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x7f, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
// 5
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xf8, 0xfc, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x0f, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x0f, 0x0f, 0x0f, 0x0f, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xfe, 0xfc, 0xfc, 0xf8, 0xf0, 0xc0, 0x80, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x07, 0x0f, 0x0f, 0x07, 0x07, 0x03, 0x03, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x03, 0x07, 0x0f, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0xc0, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xe0, 0xe0, 0xc0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00,
0x00, 0x00, 0x00, 0xe0, 0xf8, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xfe, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfe, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x1f, 0x07, 0x00, 0x00, 0x00,
0x00, 0x00, 0x03, 0x07, 0x0f, 0x1f, 0x1f, 0x3f, 0x3f, 0x7f, 0x7f, 0x7f, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x7f, 0x7f, 0x3f, 0x3f, 0x3f, 0x1f, 0x0f, 0x0f, 0x07, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
// 6
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xc0, 0xe0, 0xf0, 0xf0, 0xf8, 0xfc, 0xfc, 0xfc, 0xfe, 0xfe, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xfe, 0xfe, 0x7c, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xf0, 0xfc, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x3f, 0x1f, 0x0f, 0x07, 0x07, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x07, 0x07, 0x0f, 0x1f, 0x0f, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xc0, 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x07, 0x03, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xfe, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xfe, 0xfc, 0xf0, 0xe0, 0x80, 0x00, 0x00, 0x00, 0x00,
0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x0f, 0x07, 0x03, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x03, 0x0f, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xe0, 0x00, 0x00,
0x00, 0x03, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00,
0x00, 0x00, 0x00, 0x07, 0x1f, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xfc, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xfc, 0xfc, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x1f, 0x03, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x1f, 0x3f, 0x7f, 0x7f, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x7f, 0x7f, 0x3f, 0x3f, 0x1f, 0x0f, 0x0f, 0x07, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
// 7
0x00, 0x00, 0x00, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfc, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0x7f, 0x3f, 0x1f, 0x0f, 0x0f, 0x0f, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0xc7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x1f, 0x07, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xe0, 0xf0, 0xfc, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x1f, 0x07, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xf0, 0xf8, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x1f, 0x07, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xf0, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x0f, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0xf0, 0xe0, 0xc0, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x0f, 0x1f, 0x3f, 0x3f, 0x7f, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x7f, 0x7f, 0x3f, 0x1f, 0x1f, 0x07, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
// 8
0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xf8, 0xfc, 0xfc, 0xfe, 0xfe, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xfe, 0xfe, 0xfc, 0xfc, 0xf8, 0xf0, 0xf0, 0xe0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0xf0, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x0f, 0x07, 0x03, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xf8, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0xe0, 0xc0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xc0, 0xe0, 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x1f, 0x03, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x07, 0x0f, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xfe, 0xfe, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc7, 0x83, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x3f, 0x1f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x1f, 0x1f, 0x3f, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xfc, 0xf8, 0xf0, 0xe0, 0x80, 0x00, 0x00,
0xf0, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x83, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x00,
0x0f, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xfc, 0xfc, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xfc, 0xfc, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x1f, 0x03, 0x00,
0x00, 0x00, 0x01, 0x03, 0x07, 0x0f, 0x0f, 0x1f, 0x3f, 0x3f, 0x3f, 0x7f, 0x7f, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x7f, 0x7f, 0x7f, 0x3f, 0x3f, 0x1f, 0x1f, 0x0f, 0x07, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00,
// 9
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xe0, 0xf0, 0xf0, 0xf8, 0xfc, 0xfc, 0xfe, 0xfe, 0xfe, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xfe, 0xfe, 0xfc, 0xfc, 0xf8, 0xf8, 0xf0, 0xe0, 0xc0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xc0, 0xf8, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x1f, 0x0f, 0x07, 0x07, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x07, 0x07, 0x0f, 0x1f, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xf8, 0xc0, 0x00, 0x00, 0x00,
0x00, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xc0, 0x00,
0x00, 0x07, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0xf0, 0xe0, 0xe0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xe0, 0xe0, 0xf0, 0xf8, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00,
0x00, 0x00, 0x00, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x3f, 0x7f, 0x7f, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x7f, 0x7f, 0x3f, 0x3f, 0x3f, 0x1f, 0x1f, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xe0, 0xf0, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x03, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xfc, 0xfe, 0xfe, 0xfc, 0xfc, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xfc, 0xfc, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x3f, 0x0f, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x38, 0x3f, 0x7f, 0x7f, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x7f, 0x7f, 0x7f, 0x3f, 0x3f, 0x1f, 0x1f, 0x0f, 0x0f, 0x07, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
#endif

119
Source/src/main.c Normal file
View File

@ -0,0 +1,119 @@
#include <stdint.h>
#include <stdlib.h>
#include <avr/io.h>
#include <util/delay.h>
#include <ssd1306xled.h>
#include "shared.h"
#include "screen/counter.h"
#define VccTreshold 3000
// Forward declarations
uint8_t hasPower();
void waitForInput();
void handleCurrentScreen();
uint16_t readVCC();
int main()
{
while (1)
{
if (hasPower())
handleCurrentScreen();
}
return 0;
}
void waitForInput()
{
// TODO go to sleep until a button is pressed
_delay_ms(1000);
}
void handleCurrentScreen()
{
handleCounterScreen();
}
uint8_t isOn = 0;
uint8_t hasPower()
{
vcc = readVCC();
// Turn display off below 3v. It holds up surprisingly well, but at around
// 1.5v it does corrupt the screen and requires reinitialization when the
// voltage is turned back up.
//
// ...although by then the battery would be damaged, but still, turning off at
// 3v means we're close enough to the recommended minimum of 2.7v for LiPo
// batteries to be safe.
//
// TODO go into a sleep cycle until the battery is recharged
if ((vcc > VccTreshold) != (isOn != 0))
{
isOn = !isOn;
if (isOn)
{
// Delay is required on power-on for the SSD1306 to initialize,
// to be sure we're simply delaying every time it's reinitialized
_delay_ms(40);
ssd1306_init();
}
ssd1306_clear();
}
return isOn;
}
// Source: http://21stdigitalhome.blogspot.nl/2014/10/trinket-attiny85-internal-temperature.html
//
// I've tried many versions and none seemed to work with my ATTiny85-20SU's.
// For example:
// https://provideyourown.com/2012/secret-arduino-voltmeter-measure-battery-voltage/
// https://github.com/cano64/ArduinoSystemStatus/blob/master/SystemStatus.cpp
// http://www.avrfreaks.net/forum/attiny-adc-using-internal-ref-measure-vcc-problem
//
// The key for me was in: ADMUX = 0x0c | _BV(REFS2);
uint16_t readVCC() {
ADCSRA |= _BV(ADEN);
// Read 1.1V reference against AVcc
// set the reference to Vcc and the measurement to the internal 1.1V reference
/*
#if defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
ADMUX = _BV(REFS0) | _BV(MUX4) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);
#elif defined (__AVR_ATtiny24__) || defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__)
ADMUX = _BV(MUX5) | _BV(MUX0);
#elif defined (__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__)
ADMUX = _BV(MUX3) | _BV(MUX2);
#else
ADMUX = _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);
#endif
*/
ADMUX = 0x0c | _BV(REFS2);
_delay_ms(100);
ADCSRA |= _BV(ADSC);
while (bit_is_set(ADCSRA,ADSC));
uint16_t result = ADC;
ADCSRA &= ~(_BV(ADEN));
return result == 0 ? 0 : 1125300L / result; // Calculate Vcc (in mV); 1125300 = 1.1*1023*1000
}

View File

@ -0,0 +1,87 @@
#include <stdint.h>
#include <ssd1306xled.h>
#include "counter.h"
void handleCounterScreen()
{
drawCounter(counter);
}
void drawCounter(uint16_t value)
{
if (value > 999) value = 999;
uint8_t column = DigitFullOffset;
if (value < 10)
{
// Single digit, blank left and right (prevents flicker)
blankDigitColumn(&column, SpacingLeft1);
drawDigit(&column, value);
blankDigitColumn(&column, SpacingRight1);
}
else if (value < 100)
{
// Two digits, similar but also blank the spacing
blankDigitColumn(&column, SpacingLeft2);
drawDigit(&column, value / 10);
blankDigitColumn(&column, DigitSpacing);
drawDigit(&column, value % 10);
blankDigitColumn(&column, SpacingRight2);
}
else
{
// Three digits, you know the drill by now
drawDigit(&column, value / 100);
blankDigitColumn(&column, DigitSpacing);
drawDigit(&column, (value % 100) / 10);
blankDigitColumn(&column, DigitSpacing);
drawDigit(&column, value % 10);
}
}
void drawDigit(uint8_t* column, uint8_t digit)
{
if (digit > 9) return;
uint8_t yEnd = DigitPage + DigitRows;
uint16_t bitmapOffset = digit * DigitBytesPerChar;
for (uint8_t y = DigitPage; y < yEnd; y++)
{
ssd1306_setpos(*column, y);
ssd1306_send_data_start();
for (uint8_t x = 0; x < DigitWidth; x++)
{
ssd1306_send_byte(pgm_read_byte(&Digits[bitmapOffset]));
bitmapOffset++;
}
ssd1306_send_data_stop();
}
(*column) += DigitWidth;
}
void blankDigitColumn(uint8_t* column, uint8_t width)
{
uint8_t yEnd = DigitPage + DigitRows;
for (uint8_t y = DigitPage; y < yEnd; y++)
{
ssd1306_setpos(*column, y);
ssd1306_send_data_start();
for (uint8_t i = 0; i < width; i++)
ssd1306_send_byte(0);
ssd1306_send_data_stop();
}
(*column) += width;
}

View File

@ -0,0 +1,38 @@
#ifndef __ScreenCounter
#define __ScreenCounter
#include "shared.h"
#include "digits.h"
#define DigitPage 0
#define DisplayWidth 128
#define DisplayHeight 64
#define DigitSpacing 1
#define DigitWidth3 ((DigitWidth * 3) + (DigitSpacing * 2))
#define DigitOffset3 ((DisplayWidth - DigitWidth3) / 2)
#define DigitFullWidth DigitWidth3
#define DigitFullOffset DigitOffset3
#define DigitWidth2 ((DigitWidth * 2) + DigitSpacing)
#define DigitOffset2 ((DisplayWidth - DigitWidth2) / 2)
#define SpacingLeft2 ((DigitFullWidth - DigitWidth2) / 2)
#define SpacingRight2 (DigitFullWidth - DigitWidth2 - SpacingLeft2)
#define DigitWidth1 DigitWidth
#define DigitOffset1 ((DisplayWidth - DigitWidth1) / 2)
#define SpacingLeft1 ((DigitFullWidth - DigitWidth1) / 2)
#define SpacingRight1 (DigitFullWidth - DigitWidth1 - SpacingLeft1)
void handleCounterScreen();
void drawCounter(uint16_t value);
void drawDigit(uint8_t* column, uint8_t digit);
void blankDigitColumn(uint8_t* column, uint8_t width);
#endif

7
Source/src/shared.h Normal file
View File

@ -0,0 +1,7 @@
#ifndef __Shared
#define __Shared
uint16_t vcc;
uint16_t counter = 0;
#endif

1
Source/upload.ps1 Normal file
View File

@ -0,0 +1 @@
& platformio run --target upload