Merge pull request #27 from noisymime/master
update from josh master 10022017
This commit is contained in:
commit
73abe000ba
|
@ -10,3 +10,7 @@ table.py
|
|||
reference/hardware/v0.2/~$schematic v0.2_bom.xlsx
|
||||
|
||||
reference/hardware/v0.4/gerbers/Archive.zip
|
||||
.pioenvs
|
||||
.piolibdeps
|
||||
.clang_complete
|
||||
.gcc-flags.json
|
||||
|
|
|
@ -0,0 +1,65 @@
|
|||
# Continuous Integration (CI) is the practice, in software
|
||||
# engineering, of merging all developer working copies with a shared mainline
|
||||
# several times a day < http://docs.platformio.org/page/ci/index.html >
|
||||
#
|
||||
# Documentation:
|
||||
#
|
||||
# * Travis CI Embedded Builds with PlatformIO
|
||||
# < https://docs.travis-ci.com/user/integration/platformio/ >
|
||||
#
|
||||
# * PlatformIO integration with Travis CI
|
||||
# < http://docs.platformio.org/page/ci/travis.html >
|
||||
#
|
||||
# * User Guide for `platformio ci` command
|
||||
# < http://docs.platformio.org/page/userguide/cmd_ci.html >
|
||||
#
|
||||
#
|
||||
# Please choice one of the following templates (proposed below) and uncomment
|
||||
# it (remove "# " before each line) or use own configuration according to the
|
||||
# Travis CI documentation (see above).
|
||||
#
|
||||
|
||||
|
||||
#
|
||||
# Template #1: General project. Test it using existing `platformio.ini`.
|
||||
#
|
||||
|
||||
# language: python
|
||||
# python:
|
||||
# - "2.7"
|
||||
#
|
||||
# sudo: false
|
||||
# cache:
|
||||
# directories:
|
||||
# - "~/.platformio"
|
||||
#
|
||||
# install:
|
||||
# - pip install -U platformio
|
||||
#
|
||||
# script:
|
||||
# - platformio run
|
||||
|
||||
|
||||
#
|
||||
# Template #2: The project is intended to by used as a library with examples
|
||||
#
|
||||
|
||||
# language: python
|
||||
# python:
|
||||
# - "2.7"
|
||||
#
|
||||
# sudo: false
|
||||
# cache:
|
||||
# directories:
|
||||
# - "~/.platformio"
|
||||
#
|
||||
# env:
|
||||
# - PLATFORMIO_CI_SRC=path/to/test/file.c
|
||||
# - PLATFORMIO_CI_SRC=examples/file.ino
|
||||
# - PLATFORMIO_CI_SRC=path/to/test/directory
|
||||
#
|
||||
# install:
|
||||
# - pip install -U platformio
|
||||
#
|
||||
# script:
|
||||
# - platformio ci --lib="." --board=ID_1 --board=ID_2 --board=ID_N
|
|
@ -0,0 +1,36 @@
|
|||
|
||||
This directory is intended for the project specific (private) libraries.
|
||||
PlatformIO will compile them to static libraries and link to executable file.
|
||||
|
||||
The source code of each library should be placed in separate directory, like
|
||||
"lib/private_lib/[here are source files]".
|
||||
|
||||
For example, see how can be organized `Foo` and `Bar` libraries:
|
||||
|
||||
|--lib
|
||||
| |--Bar
|
||||
| | |--docs
|
||||
| | |--examples
|
||||
| | |--src
|
||||
| | |- Bar.c
|
||||
| | |- Bar.h
|
||||
| |--Foo
|
||||
| | |- Foo.c
|
||||
| | |- Foo.h
|
||||
| |- readme.txt --> THIS FILE
|
||||
|- platformio.ini
|
||||
|--src
|
||||
|- main.c
|
||||
|
||||
Then in `src/main.c` you should use:
|
||||
|
||||
#include <Foo.h>
|
||||
#include <Bar.h>
|
||||
|
||||
// rest H/C/CPP code
|
||||
|
||||
PlatformIO will find your libraries automatically, configure preprocessor's
|
||||
include paths and build them.
|
||||
|
||||
More information about PlatformIO Library Dependency Finder
|
||||
- http://docs.platformio.org/page/librarymanager/ldf.html
|
6
maths.h
6
maths.h
|
@ -1,6 +0,0 @@
|
|||
#ifndef MATH_H
|
||||
#define MATH_H
|
||||
|
||||
int fastMap1023toX(unsigned long x, int out_max);
|
||||
|
||||
#endif
|
|
@ -0,0 +1,46 @@
|
|||
; 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:megaatmega2560]
|
||||
platform=atmelavr
|
||||
board=megaatmega2560
|
||||
framework=arduino
|
||||
build_unflags = -Os
|
||||
build_flags = -O3 -ffast-math
|
||||
lib_deps = EEPROM
|
||||
|
||||
[env:teensy35]
|
||||
platform=teensy
|
||||
board=teensy35
|
||||
framework=arduino
|
||||
lib_deps = EEPROM, FlexCAN
|
||||
|
||||
[env:LaunchPad_tm4c1294ncpdt]
|
||||
platform = titiva
|
||||
framework = energia
|
||||
board = lptm4c1294ncpdt
|
||||
lib_deps = EEPROM
|
||||
|
||||
[env:genericSTM32F103RB]
|
||||
platform = ststm32
|
||||
framework = arduino
|
||||
; framework-arduinoststm32
|
||||
board = genericSTM32F103RB
|
||||
lib_deps = EEPROM
|
||||
build_flags = -fpermissive
|
||||
|
||||
|
||||
[platformio]
|
||||
src_dir=speeduino
|
||||
env_default = megaatmega2560
|
||||
;The following lines are for testing / experimentation only. Comment the line above to try them out
|
||||
;env_default = teensy35
|
||||
;env_default = LaunchPad_tm4c1294ncpdt
|
||||
;env_default = genericSTM32F103RB
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<msq xmlns="http://www.msefi.com/:msq">
|
||||
<bibliography author="TunerStudio MS(Beta) 3.0.16 - EFI Analytics, Inc." tuneComment="" writeDate="Thu Jan 05 17:17:26 AEDT 2017"/>
|
||||
<versionInfo fileFormat="5.0" firmwareInfo="Speeduino+2016.12-dev" nPages="9" signature="speeduino 201612"/>
|
||||
<bibliography author="TunerStudio MS(Beta) 3.0.18 - EFI Analytics, Inc." tuneComment="" writeDate="Wed Feb 01 17:41:35 AEDT 2017"/>
|
||||
<versionInfo fileFormat="5.0" firmwareInfo="Speeduino+2017.01" nPages="9" signature="speeduino 201701"/>
|
||||
<page>
|
||||
<pcVariable name="tsCanId">"0"</pcVariable>
|
||||
</page>
|
||||
|
@ -43,21 +43,21 @@
|
|||
7000.0
|
||||
</constant>
|
||||
<constant cols="1" digits="0" name="mapBins" rows="16" units="kPa">
|
||||
15.0
|
||||
25.0
|
||||
16.0
|
||||
26.0
|
||||
30.0
|
||||
35.0
|
||||
36.0
|
||||
40.0
|
||||
45.0
|
||||
46.0
|
||||
50.0
|
||||
55.0
|
||||
56.0
|
||||
60.0
|
||||
65.0
|
||||
66.0
|
||||
70.0
|
||||
75.0
|
||||
85.0
|
||||
76.0
|
||||
86.0
|
||||
90.0
|
||||
95.0
|
||||
96.0
|
||||
100.0
|
||||
</constant>
|
||||
</page>
|
||||
|
@ -81,7 +81,7 @@
|
|||
<constant digits="0" name="crankingPct" units="%">20.0</constant>
|
||||
<constant name="pinLayout">"Speeduino v0.4"</constant>
|
||||
<constant name="tachoPin">"Board Default"</constant>
|
||||
<constant name="unused2-16f">"One"</constant>
|
||||
<constant name="tachoDiv">"Normal"</constant>
|
||||
<constant digits="1" name="tdePct" units="ms">3.2</constant>
|
||||
<constant digits="1" name="taeColdA" units="ms">0.0</constant>
|
||||
<constant digits="0" name="tpsThresh" units="%/s">70.0</constant>
|
||||
|
@ -103,7 +103,7 @@
|
|||
<constant name="unused2-26e">"No"</constant>
|
||||
<constant name="unused2-26f">"No"</constant>
|
||||
<constant name="unused2-26g">"Yes"</constant>
|
||||
<constant name="unused2-26h">"No"</constant>
|
||||
<constant name="indInjAng">"Enabled"</constant>
|
||||
<constant digits="1" name="injOpen" units="ms">1.0</constant>
|
||||
<constant digits="0" name="inj1Ang" units="deg">355.0</constant>
|
||||
<constant digits="0" name="inj2Ang" units="deg">355.0</constant>
|
||||
|
@ -156,7 +156,7 @@
|
|||
17.0 20.0 20.0 20.0 21.0 23.0 23.0 24.0 25.0 26.0 27.0 28.0 29.0 29.0 30.0 31.0
|
||||
17.0 20.0 20.0 20.0 21.0 22.0 22.0 23.0 24.0 25.0 26.0 27.0 28.0 28.0 29.0 30.0
|
||||
18.0 18.0 18.0 18.0 21.0 21.0 21.0 21.0 21.0 21.0 21.0 20.0 19.0 20.0 20.0 20.0
|
||||
18.0 18.0 18.0 18.0 20.0 20.0 20.0 20.0 19.0 16.0 19.0 18.0 18.0 18.0 18.0 18.0
|
||||
18.0 18.0 18.0 18.0 20.0 20.0 20.0 20.0 19.0 19.0 19.0 18.0 18.0 18.0 18.0 18.0
|
||||
18.0 18.0 18.0 18.0 18.0 18.0 18.0 18.0 17.0 17.0 17.0 16.0 16.0 16.0 16.0 16.0
|
||||
18.0 18.0 18.0 18.0 17.0 17.0 17.0 17.0 16.0 16.0 16.0 15.0 15.0 15.0 15.0 15.0
|
||||
18.0 18.0 18.0 18.0 16.0 16.0 16.0 16.0 15.0 15.0 15.0 14.0 14.0 14.0 14.0 14.0
|
||||
|
@ -183,22 +183,22 @@
|
|||
7700.0
|
||||
</constant>
|
||||
<constant cols="1" digits="0" name="mapBins2" rows="16" units="kPa">
|
||||
10.0
|
||||
16.0
|
||||
20.0
|
||||
26.0
|
||||
30.0
|
||||
36.0
|
||||
40.0
|
||||
46.0
|
||||
50.0
|
||||
60.0
|
||||
70.0
|
||||
56.0
|
||||
66.0
|
||||
74.0
|
||||
80.0
|
||||
90.0
|
||||
100.0
|
||||
115.0
|
||||
130.0
|
||||
145.0
|
||||
160.0
|
||||
175.0
|
||||
190.0
|
||||
205.0
|
||||
88.0
|
||||
96.0
|
||||
104.0
|
||||
</constant>
|
||||
</page>
|
||||
<page number="3" size="64">
|
||||
|
@ -288,7 +288,7 @@
|
|||
<constant digits="0" name="dfcoHyster" units="RPM">200.0</constant>
|
||||
<constant digits="0" name="dfcoTPSThresh" units="%">1.0</constant>
|
||||
<constant name="ignBypassEnable">"Off"</constant>
|
||||
<constant name="ignBypassPin">"1"</constant>
|
||||
<constant name="ignBypassPin">"3"</constant>
|
||||
<constant name="ignBypassHiLo">"LOW"</constant>
|
||||
</page>
|
||||
<page number="4" size="288">
|
||||
|
@ -329,21 +329,21 @@
|
|||
7000.0
|
||||
</constant>
|
||||
<constant cols="1" digits="0" name="mapBinsAFR" rows="16" units="kPa">
|
||||
15.0
|
||||
25.0
|
||||
16.0
|
||||
26.0
|
||||
30.0
|
||||
35.0
|
||||
36.0
|
||||
40.0
|
||||
45.0
|
||||
46.0
|
||||
50.0
|
||||
55.0
|
||||
56.0
|
||||
60.0
|
||||
65.0
|
||||
66.0
|
||||
70.0
|
||||
75.0
|
||||
85.0
|
||||
76.0
|
||||
86.0
|
||||
90.0
|
||||
95.0
|
||||
96.0
|
||||
100.0
|
||||
</constant>
|
||||
</page>
|
||||
|
@ -365,8 +365,12 @@
|
|||
<constant digits="0" name="ego_sdelay" units="sec">15.0</constant>
|
||||
<constant digits="0" name="egoRPM" units="rpm">1200.0</constant>
|
||||
<constant digits="0" name="egoTPSMax" units="%">70.0</constant>
|
||||
<constant digits="0" name="egoLoadMax" units="%">90.0</constant>
|
||||
<constant digits="0" name="egoLoadMin" units="%">20.0</constant>
|
||||
<constant name="vvtPin">"26"</constant>
|
||||
<constant name="unused6-13e">"ONE"</constant>
|
||||
<constant name="unused6-13f">"ONE"</constant>
|
||||
<constant name="boostPin">"20"</constant>
|
||||
<constant name="unused6-14e">"ONE"</constant>
|
||||
<constant name="unused6-14f">"ONE"</constant>
|
||||
<constant cols="1" digits="1" name="brvBins" rows="6" units="V">
|
||||
6.6
|
||||
9.4
|
||||
|
@ -408,13 +412,13 @@
|
|||
<constant digits="0" name="boostFreq" units="Hz">30.0</constant>
|
||||
<constant digits="0" name="vvtFreq" units="Hz">300.0</constant>
|
||||
<constant digits="0" name="idleFreq" units="Hz">120.0</constant>
|
||||
<constant name="launchPin">"1"</constant>
|
||||
<constant name="launchPin">"Board Default"</constant>
|
||||
<constant name="launchEnable">"No"</constant>
|
||||
<constant name="launchHiLo">"LOW"</constant>
|
||||
<constant digits="0" name="lnchSoftLim" units="rpm">3500.0</constant>
|
||||
<constant digits="0" name="lnchRetard" units="deg">15.0</constant>
|
||||
<constant digits="0" name="lnchHardLim" units="rpm">4000.0</constant>
|
||||
<constant digits="0" name="lnchFuelAdd" units="%">255.0</constant>
|
||||
<constant digits="0" name="lnchFuelAdd" units="%">50.0</constant>
|
||||
<constant digits="0" name="idleKP" units="%">10.0</constant>
|
||||
<constant digits="0" name="idleKI" units="%">0.0</constant>
|
||||
<constant digits="0" name="idleKD" units="%">5.0</constant>
|
||||
|
@ -422,16 +426,16 @@
|
|||
<constant digits="0" name="boostKP" units="%">100.0</constant>
|
||||
<constant digits="0" name="boostKI" units="%">0.0</constant>
|
||||
<constant digits="0" name="boostKD" units="%">0.0</constant>
|
||||
<constant name="lnchPullRes">"Float"</constant>
|
||||
<constant name="lnchPullRes">"Pullup"</constant>
|
||||
<constant name="fuelTrimEnabled">"No"</constant>
|
||||
<constant name="unused6-60d">"ONE"</constant>
|
||||
<constant name="flatSEnable">"No"</constant>
|
||||
<constant name="unused6-60e">"ONE"</constant>
|
||||
<constant name="unused6-60f">"ONE"</constant>
|
||||
<constant name="unused6-60g">"ONE"</constant>
|
||||
<constant name="unused6-60h">"ONE"</constant>
|
||||
<constant digits="0" name="unused6-61" units="RPM">4500.0</constant>
|
||||
<constant digits="0" name="unused6-62" units="RPM">3000.0</constant>
|
||||
<constant digits="0" name="unused6-63" units="RPM">6000.0</constant>
|
||||
<constant digits="0" name="flatSSoftWin" units="rpm">400.0</constant>
|
||||
<constant digits="0" name="flatSRetard" units="deg">5.0</constant>
|
||||
<constant digits="0" name="flatSArm" units="rpm">2000.0</constant>
|
||||
</page>
|
||||
<page number="6" size="64">
|
||||
<constant cols="1" digits="0" name="iacCLValues" rows="10" units="RPM">
|
||||
|
@ -600,9 +604,9 @@
|
|||
7000.0
|
||||
</constant>
|
||||
<constant cols="1" digits="0" name="fuelTrim1loadBins" rows="6" units="kPa">
|
||||
35.0
|
||||
36.0
|
||||
50.0
|
||||
65.0
|
||||
66.0
|
||||
80.0
|
||||
100.0
|
||||
120.0
|
||||
|
@ -624,9 +628,9 @@
|
|||
7000.0
|
||||
</constant>
|
||||
<constant cols="1" digits="0" name="fuelTrim2loadBins" rows="6" units="kPa">
|
||||
35.0
|
||||
36.0
|
||||
50.0
|
||||
65.0
|
||||
66.0
|
||||
80.0
|
||||
100.0
|
||||
120.0
|
||||
|
@ -648,9 +652,9 @@
|
|||
7000.0
|
||||
</constant>
|
||||
<constant cols="1" digits="0" name="fuelTrim3loadBins" rows="6" units="kPa">
|
||||
35.0
|
||||
36.0
|
||||
50.0
|
||||
65.0
|
||||
66.0
|
||||
80.0
|
||||
100.0
|
||||
120.0
|
||||
|
@ -672,9 +676,9 @@
|
|||
7000.0
|
||||
</constant>
|
||||
<constant cols="1" digits="0" name="fuelTrim4loadBins" rows="6" units="kPa">
|
||||
35.0
|
||||
36.0
|
||||
50.0
|
||||
65.0
|
||||
66.0
|
||||
80.0
|
||||
100.0
|
||||
120.0
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
;-------------------------------------------------------------------------------
|
||||
;-------------------------------------------------------------------------------
|
||||
#unset CAN_COMMANDS
|
||||
|
||||
[MegaTune]
|
||||
|
@ -6,7 +6,7 @@
|
|||
|
||||
queryCommand = "Q"
|
||||
;signature = 20
|
||||
signature = "speeduino 201701-dev"
|
||||
signature = "speeduino 201702-dev"
|
||||
versionInfo = "S" ; Put this in the title bar.
|
||||
|
||||
|
||||
|
@ -22,9 +22,9 @@
|
|||
; folder. If is is an undefined referenceName, it will be added.
|
||||
; keyword = referenceName, DisplayName
|
||||
|
||||
settingGroup = boostUnits, "Boost table units"
|
||||
settingOption = DEFAULT, "kPa"
|
||||
settingOption = BOOSTPSI, "PSI"
|
||||
;settingGroup = boostUnits, "Boost table units"
|
||||
;settingOption = DEFAULT, "kPa"
|
||||
;settingOption = BOOSTPSI, "PSI"
|
||||
|
||||
[PcVariables]
|
||||
; valid types: boolean, double, int, list
|
||||
|
@ -168,7 +168,7 @@ page = 2
|
|||
unused2-26e= bits, U08, 26, [4:4], "No", "Yes"
|
||||
unused2-26f= bits, U08, 26, [5:5], "No", "Yes"
|
||||
unused2-26g= bits, U08, 26, [6:6], "No", "Yes"
|
||||
unused2-26h= bits, U08, 26, [7:7], "No", "Yes"
|
||||
indInjAng = bits, U08, 26, [7:7], "Disabled", "Enabled"
|
||||
injOpen = scalar, U08, 27, "ms", 0.1, 0.0, 0.1, 25.5, 1
|
||||
inj1Ang = scalar, U16, 28, "deg", 1.0, 0.0, 0.0, 360, 0
|
||||
inj2Ang = scalar, U16, 30, "deg", 1.0, 0.0, 0.0, 360, 0
|
||||
|
@ -249,7 +249,7 @@ page = 4
|
|||
oddfire = bits, U08, 5,[3:3], "No", "Yes"
|
||||
TrigPattern= bits, U08, 5,[4:7], "Missing Tooth", "Basic Distributor", "Dual Wheel", "GM 7X", "4G63 / Miata", "GM 24X", "Jeep 2000", "Audi 135", "Honda D17", "Miata 99-05", "Mazda AU", "Non-360 Dual", "INVALID", "INVALID", "INVALID", "INVALID"
|
||||
TrigEdgeSec= bits, U08, 6,[0:0], "Leading", "Trailing"
|
||||
fuelPumpPin= bits , U08, 6,[1:6], "Board Default", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "54", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID"
|
||||
fuelPumpPin= bits , U08, 6,[1:6], "Board Default", "INVALID", "INVALID", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "54", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID"
|
||||
unused4-6h = bits, U08, 6,[7:7], "No", "Yes"
|
||||
unused4-7 = scalar, U08, 7, "ADC", 1, 0, 0, 255, 0
|
||||
IdleAdvRPM = scalar, U08, 8, "RPM", 100, 0, 0, 1200, 0
|
||||
|
@ -311,7 +311,7 @@ page = 4
|
|||
dfcoTPSThresh= scalar, U08, 62, "%", 1.0, 0.0, 0, 100.0, 0
|
||||
;ranking ignition bypass
|
||||
ignBypassEnable = bits, U08, 63, [0:0], "Off", "On"
|
||||
ignBypassPin = bits , U08, 63, [1:6], "INVALID", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "54", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID"
|
||||
ignBypassPin = bits , U08, 63, [1:6], "INVALID", "INVALID", "INVALID", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "54", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID"
|
||||
ignBypassHiLo = bits, U08, 63, [7:7], "LOW", "HIGH"
|
||||
|
||||
|
||||
|
@ -357,10 +357,10 @@ page = 6
|
|||
ego_sdelay = scalar, U08, 10, "sec", 1, 0, 0, 120, 0
|
||||
egoRPM = scalar, U08, 11, "rpm", 100, 0.0, 100, 25500, 0
|
||||
egoTPSMax = scalar, U08, 12, "%", 1, 0, 0, 120, 0
|
||||
vvtPin = bits , U08, 13, [0:5], "Board Default", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "54", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID"
|
||||
vvtPin = bits , U08, 13, [0:5], "Board Default", "INVALID", "INVALID", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "54", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID"
|
||||
unused6-13e = bits, U08, 13, [6:6], "ONE", "INVALID"
|
||||
unused6-13f = bits, U08, 13, [7:7], "ONE", "INVALID"
|
||||
boostPin = bits, U08, 14, [0:5], "Board Default", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "54", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID"
|
||||
boostPin = bits, U08, 14, [0:5], "Board Default", "INVALID", "INVALID", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "54", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID"
|
||||
unused6-14e = bits, U08, 14, [6:6], "ONE", "INVALID"
|
||||
unused6-14f = bits, U08, 14, [7:7], "ONE", "INVALID"
|
||||
brvBins = array, U08, 15, [6], "V", 0.1, 0, 6, 24, 1 ; Bins for the battery reference voltage
|
||||
|
@ -378,7 +378,7 @@ page = 6
|
|||
idleFreq = scalar, U08, 47, "Hz", 2.0, 0.0, 10, 511, 0
|
||||
|
||||
; Launch Control
|
||||
launchPin = bits , U08, 48, [0:5], "Board Default", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "54", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID"
|
||||
launchPin = bits , U08, 48, [0:5], "Board Default", "INVALID", "INVALID", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "54", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID"
|
||||
launchEnable= bits, U08, 48, [6:6], "No", "Yes"
|
||||
launchHiLo = bits, U08, 48, [7:7], "LOW", "HIGH"
|
||||
|
||||
|
@ -445,13 +445,13 @@ page = 7
|
|||
; Begin fan control vairables
|
||||
fanInv = bits, U08, 56, [0:0], "No", "Yes"
|
||||
fanEnable = bits, U08, 56, [1:1], "Off", "On/Off"
|
||||
fanPin = bits , U08, 56, [2:7], "Board Default", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "54", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID"
|
||||
fanPin = bits , U08, 56, [2:7], "Board Default", "INVALID", "INVALID", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "54", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID"
|
||||
#if CELSIUS
|
||||
fanSP = scalar, U08, 57, "C", 1.0, -40, -40, 215.0, 0
|
||||
fanHyster = scalar, U08, 58, "C", 1.0, -40, -40, 215.0, 0
|
||||
fanHyster = scalar, U08, 58, "C", 1.0, 0.0, 0.0, 40, 0
|
||||
#else
|
||||
fanSP = scalar, U08, 57, "F", 1.8, -22.23, -40, 215.0, 0
|
||||
fanHyster = scalar, U08, 58, "F", 1.8, -22.23, -40, 215.0, 0
|
||||
fanHyster = scalar, U08, 58, "F", 1.0, 0.0, 0.0, 40, 0
|
||||
#endif
|
||||
fanFreq = scalar, U08 , 59, "Hz", 2.0, 0.0, 10, 511, 0
|
||||
#if CELSIUS
|
||||
|
@ -465,12 +465,11 @@ page = 7
|
|||
;--------------------------------------------------
|
||||
page = 8
|
||||
;notes for boostTable in PSI~~~There are 6.895 psis to a kPa then x 2 like the kPa ver~~~div atmos. pressure in kPa by 2 and make neg so to subtract instead of add
|
||||
#if BOOSTPSI
|
||||
boostTable = array, U08, 0,[8x8], "PSI", 0.29007547546041846, -50.6625, 0, 74, 0
|
||||
; boostTable = array, U08, 0,[8x8], "PSI", 0.14503773773020923, -2.10304719708803, 0, 74, 0 #0.043511 0.02900754754 0.05801509508
|
||||
#else
|
||||
; #if BOOSTPSI
|
||||
; boostTable = array, U08, 0,[8x8], "PSI", 0.29007547546041846, -50.6625, 0, 74, 0
|
||||
; #else
|
||||
boostTable = array, U08, 0,[8x8], "kPa", 2.0, 0.0, 0, 511, 0
|
||||
#endif
|
||||
; #endif
|
||||
rpmBinsBoost = array, U08, 64,[ 8], "RPM", 100.0, 0.0, 100, 25500, 0
|
||||
tpsBinsBoost = array, U08, 72,[ 8], "TPS", 1.0, 0.0, 0.0, 255.0, 0
|
||||
vvtTable = array, U08, 80,[8x8], "%", 1.0, 0.0, 0, 100, 0
|
||||
|
@ -651,6 +650,7 @@ page = 10
|
|||
[ConstantsExtensions]
|
||||
requiresPowerCycle = nCylinders
|
||||
requiresPowerCycle = pinLayout
|
||||
requiresPowerCycle = fanPin
|
||||
requiresPowerCycle = reqFuel
|
||||
requiresPowerCycle = numteeth
|
||||
requiresPowerCycle = onetwo
|
||||
|
@ -675,6 +675,7 @@ page = 10
|
|||
defaultValue = pinLayout, 1
|
||||
defaultValue = TrigPattern, 0
|
||||
defaultValue = sparkMode, 0
|
||||
defaultValue = indInjAng, 0
|
||||
defaultValue = inj1Ang, 355
|
||||
defaultValue = inj2Ang, 355
|
||||
defaultValue = inj3Ang, 355
|
||||
|
@ -1023,10 +1024,12 @@ menuDialog = main
|
|||
dialog = injChars, "Injector Characteristics"
|
||||
field = "Injector Open Time", injOpen
|
||||
field = "Injector close angle"
|
||||
field = "Channel 1", inj1Ang
|
||||
field = "Channel 2", inj2Ang, { nCylinders > 1 }
|
||||
field = "Channel 3", inj3Ang, { nCylinders > 4 || nCylinders == 3 || ((nCylinders == 4) && (injLayout == 3)) }
|
||||
field = "Channel 4", inj4Ang, { nCylinders > 6 || ((nCylinders == 4) && (injLayout == 3)) }
|
||||
field = "", inj1Ang, { indInjAng == 0 }
|
||||
field = "Individual channel setting", indInjAng
|
||||
field = "Channel 1", inj1Ang, { indInjAng }
|
||||
field = "Channel 2", inj2Ang, { nCylinders > 1 && indInjAng }
|
||||
field = "Channel 3", inj3Ang, { indInjAng && (nCylinders > 4 || nCylinders == 3 || ((nCylinders == 4) && (injLayout == 3))) }
|
||||
field = "Channel 4", inj4Ang, { indInjAng && (nCylinders > 6 || ((nCylinders == 4) && (injLayout == 3))) }
|
||||
field = "Injector Duty Limit", dutyLim
|
||||
panel = injector_voltage_curve
|
||||
|
||||
|
|
|
@ -15,6 +15,8 @@ sendcancommand is called when a comman d is to be sent via serial3 to the Can in
|
|||
//#include "globals.h"
|
||||
//#include "storage.h"
|
||||
|
||||
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) || defined(__AVR_ATmega2561__)
|
||||
|
||||
void canCommand()
|
||||
{
|
||||
switch (Serial3.read())
|
||||
|
@ -47,16 +49,16 @@ void canCommand()
|
|||
while (Serial3.available() == 0) { }
|
||||
Llength= Serial3.read(); // next the number of bytes expected value
|
||||
for (uint8_t Lcount = 0; Lcount <Llength ;Lcount++)
|
||||
{
|
||||
while (Serial3.available() == 0){}
|
||||
{
|
||||
while (Serial3.available() == 0){}
|
||||
// receive all x bytes into "Lbuffer"
|
||||
Lbuffer[Lcount] = Serial3.read();
|
||||
}
|
||||
break;
|
||||
|
||||
break;
|
||||
|
||||
case 'S': // send code version
|
||||
for (unsigned int sig = 0; sig < sizeof(displaySignature) - 1; sig++){
|
||||
Serial3.write(displaySignature[sig]);
|
||||
Serial3.write(displaySignature[sig]);
|
||||
}
|
||||
//Serial3.print("speeduino 201609-dev");
|
||||
break;
|
||||
|
@ -84,11 +86,17 @@ void sendCancommand(uint8_t cmdtype, uint16_t canaddress, uint8_t candata1, uint
|
|||
Serial3.write(candata1); // table id
|
||||
Serial3.write(candata2); //table memory offset
|
||||
break;
|
||||
|
||||
|
||||
case 1: //send request to listen for a can message
|
||||
Serial3.print("L");
|
||||
Serial3.write(canaddress); //11 bit canaddress of device to listen for
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
//Dummy functions for those that can't do Serial3
|
||||
void canCommand() { return; }
|
||||
void sendCancommand(uint8_t cmdtype, uint16_t canaddress, uint8_t candata1, uint8_t candata2) { return; }
|
||||
|
||||
#endif
|
|
@ -18,7 +18,7 @@ void command()
|
|||
switch (Serial.read())
|
||||
{
|
||||
case 'A': // send x bytes of realtime values
|
||||
sendValues(packetSize, 0); //send values to serial0
|
||||
sendValues(packetSize, 0); //send values to serial0
|
||||
break;
|
||||
|
||||
case 'B': // Burn current values to eeprom
|
||||
|
@ -62,12 +62,12 @@ void command()
|
|||
break;
|
||||
|
||||
case 'S': // send code version
|
||||
Serial.print("Speeduino 2017.01-dev");
|
||||
Serial.print("Speeduino 2017.02-dev");
|
||||
currentStatus.secl = 0; //This is required in TS3 due to its stricter timings
|
||||
break;
|
||||
|
||||
case 'Q': // send code version
|
||||
Serial.print("speeduino 201701-dev");
|
||||
Serial.print("speeduino 201702-dev");
|
||||
break;
|
||||
|
||||
case 'V': // send VE table and constants in binary
|
||||
|
@ -154,7 +154,7 @@ void command()
|
|||
sendToothLog(true); //Sends tooth log values as chars
|
||||
break;
|
||||
|
||||
|
||||
|
||||
|
||||
case '?':
|
||||
Serial.println
|
||||
|
@ -201,7 +201,7 @@ This function returns the current values of a fixed group of variables
|
|||
void sendValues(int packetlength, byte portNum)
|
||||
{
|
||||
byte response[packetlength];
|
||||
|
||||
|
||||
if (portNum == 3)
|
||||
{
|
||||
//CAN serial
|
||||
|
@ -209,13 +209,13 @@ void sendValues(int packetlength, byte portNum)
|
|||
Serial3.write(packetlength); //confirm no of byte to be sent
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
if(requestCount == 0) { currentStatus.secl = 0; }
|
||||
requestCount++;
|
||||
}
|
||||
|
||||
currentStatus.spark ^= (-currentStatus.hasSync ^ currentStatus.spark) & (1 << BIT_SPARK_SYNC); //Set the sync bit of the Spark variable to match the hasSync variable
|
||||
|
||||
|
||||
response[0] = currentStatus.secl; //secl is simply a counter that increments each second. Used to track unexpected resets (Which will reset this count to 0)
|
||||
response[1] = currentStatus.squirt; //Squirt Bitfield
|
||||
response[2] = currentStatus.engine; //Engine Status Bitfield
|
||||
|
@ -252,7 +252,7 @@ void sendValues(int packetlength, byte portNum)
|
|||
response[28] = currentStatus.batCorrection; //Battery voltage correction (%)
|
||||
response[29] = currentStatus.spark; //Spark related bitfield
|
||||
response[30] = currentStatus.O2_2; //O2
|
||||
|
||||
|
||||
//rpmDOT must be sent as a signed integer
|
||||
response[31] = lowByte(currentStatus.rpmDOT);
|
||||
response[32] = highByte(currentStatus.rpmDOT);
|
||||
|
@ -261,7 +261,7 @@ void sendValues(int packetlength, byte portNum)
|
|||
response[34] = currentStatus.flexCorrection; //Flex fuel correction (% above or below 100)
|
||||
response[35] = currentStatus.flexIgnCorrection; //Ignition correction (Increased degrees of advance) for flex fuel
|
||||
response[36] = getNextError();
|
||||
|
||||
|
||||
//cli();
|
||||
if (portNum == 0) { Serial.write(response, (size_t)packetlength); }
|
||||
else if (portNum == 3) { Serial3.write(response, (size_t)packetlength); }
|
||||
|
@ -395,7 +395,7 @@ void receiveValue(int valueOffset, byte newValue)
|
|||
}
|
||||
else if (valueOffset < 80) //New value is on the Y (TPS) axis of the boost table
|
||||
{
|
||||
boostTable.axisY[(7 - (valueOffset - 72))] = int(newValue) * TABLE_LOAD_MULTIPLIER;
|
||||
boostTable.axisY[(7 - (valueOffset - 72))] = int(newValue); //TABLE_LOAD_MULTIPLIER is NOT used for boost as it is TPS based (0-100)
|
||||
return;
|
||||
}
|
||||
else if (valueOffset < 144) //New value is part of the vvt map
|
||||
|
@ -413,7 +413,7 @@ void receiveValue(int valueOffset, byte newValue)
|
|||
else //New value is on the Y (Load) axis of the vvt table
|
||||
{
|
||||
valueOffset = valueOffset - 152;
|
||||
vvtTable.axisY[(7 - valueOffset)] = int(newValue) * TABLE_LOAD_MULTIPLIER;
|
||||
vvtTable.axisY[(7 - valueOffset)] = int(newValue); //TABLE_LOAD_MULTIPLIER is NOT used for vvt as it is TPS based (0-100)
|
||||
return;
|
||||
}
|
||||
case seqFuelPage:
|
||||
|
@ -441,9 +441,9 @@ void receiveValue(int valueOffset, byte newValue)
|
|||
if (valueOffset < npage_size[currentPage])
|
||||
{
|
||||
*((byte *)pnt_configPage + (byte)valueOffset) = newValue;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -574,7 +574,7 @@ void sendPage(bool useChar)
|
|||
{
|
||||
//To Display Values from Config Page 3
|
||||
Serial.println((const __FlashStringHelper *)&pageTitles[91]);//special typecasting to enable suroutine that the F macro uses
|
||||
for (pnt_configPage = &configPage3; pnt_configPage < &configPage3.voltageCorrectionBins[0]; pnt_configPage = (byte *)pnt_configPage + 1)
|
||||
for (pnt_configPage = &configPage3; pnt_configPage < &configPage3.voltageCorrectionBins[0]; pnt_configPage = (byte *)pnt_configPage + 1)
|
||||
{
|
||||
Serial.println(*((byte *)pnt_configPage));// Displaying byte values of config page 3 up to but not including the first array
|
||||
}
|
||||
|
@ -673,7 +673,7 @@ void sendPage(bool useChar)
|
|||
}
|
||||
else
|
||||
{
|
||||
//Need to perform a translation of the values[MAP/TPS][RPM] into the MS expected format
|
||||
//Need to perform a translation of the values[MAP/TPS][RPM] into the MS expected format
|
||||
byte response[160]; //Bit hacky, but the size is: (8x8 + 8 + 8) + (8x8 + 8 + 8) = 160
|
||||
|
||||
//Boost table
|
||||
|
@ -690,7 +690,7 @@ void sendPage(bool useChar)
|
|||
break;
|
||||
}
|
||||
case seqFuelPage:
|
||||
{
|
||||
{
|
||||
if(useChar)
|
||||
{
|
||||
currentTable = trim1Table;
|
||||
|
@ -728,9 +728,9 @@ void sendPage(bool useChar)
|
|||
}
|
||||
else
|
||||
{
|
||||
//Need to perform a translation of the values[MAP/TPS][RPM] into the MS expected format
|
||||
//Need to perform a translation of the values[MAP/TPS][RPM] into the MS expected format
|
||||
byte response[192]; //Bit hacky, but the size is: (6x6 + 6 + 6) * 4 = 192
|
||||
|
||||
|
||||
//trim1 table
|
||||
for (int x = 0; x < 36; x++) { response[x] = trim1Table.values[5 - x / 6][x % 6]; }
|
||||
for (int x = 36; x < 42; x++) { response[x] = byte(trim1Table.axisX[(x - 36)] / TABLE_RPM_MULTIPLIER); }
|
||||
|
@ -760,7 +760,7 @@ void sendPage(bool useChar)
|
|||
{
|
||||
//To Display Values from Config Page 10
|
||||
Serial.println((const __FlashStringHelper *)&pageTitles[141]);//special typecasting to enable suroutine that the F macro uses
|
||||
for (pnt_configPage = &configPage10; pnt_configPage < ((byte *)pnt_configPage + 128); pnt_configPage = (byte *)pnt_configPage + 1)
|
||||
for (pnt_configPage = &configPage10; pnt_configPage < ((byte *)pnt_configPage + 128); pnt_configPage = (byte *)pnt_configPage + 1)
|
||||
{
|
||||
Serial.println(*((byte *)pnt_configPage));// Displaying byte values of config page 3 up to but not including the first array
|
||||
}
|
||||
|
@ -769,7 +769,7 @@ void sendPage(bool useChar)
|
|||
else pnt_configPage = &configPage10; //Create a pointer to Page 10 in memory
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
default:
|
||||
{
|
||||
Serial.println(F("\nPage has not been implemented yet. Change to another page."));
|
||||
|
@ -880,7 +880,7 @@ void sendPage(bool useChar)
|
|||
response[x] = *((byte *)pnt_configPage + x); //Each byte is simply the location in memory of the configPage + the offset + the variable number (x)
|
||||
//if ( (x & 31) == 1) { loop(); } //Every 32 loops, do a manual call to loop() to ensure that there is no misses
|
||||
}
|
||||
|
||||
|
||||
Serial.write((byte *)&response, sizeof(response));
|
||||
// }
|
||||
}
|
||||
|
@ -970,7 +970,7 @@ void receiveCalibration(byte tableID)
|
|||
|
||||
//From TS3.x onwards, the EEPROM must be written here as TS restarts immediately after the process completes which is before the EEPROM write completes
|
||||
int y = EEPROM_START + (x / 2);
|
||||
EEPROM.update(y, (byte)tempValue);
|
||||
EEPROM.update(y, (byte)tempValue);
|
||||
|
||||
every2nd = false;
|
||||
analogWrite(13, (counter % 50) );
|
File diff suppressed because it is too large
Load Diff
|
@ -4,6 +4,8 @@ Copyright (C) Josh Stewart
|
|||
A full copy of the license may be found in the projects root directory
|
||||
*/
|
||||
|
||||
#ifdef USE_DISPLAY
|
||||
|
||||
#include <SPI.h>
|
||||
#include <Wire.h>
|
||||
#include "src/Adafruit_SSD1306/Adafruit_GFX.h"
|
||||
|
@ -15,7 +17,7 @@ void initialiseDisplay()
|
|||
{
|
||||
//Protection against older pin mappings where the crank/cam signals were on the SDA and SCL pins. This will cause the Arduino to lock hard if you try to initialise i2c devices when a crank signal is coming in
|
||||
if(pinTrigger == 20 || pinTrigger == 21 || pinTrigger2 == 20 || pinTrigger2 == 21) { return; }
|
||||
|
||||
|
||||
switch(configPage1.displayType)
|
||||
{
|
||||
case 1:
|
||||
|
@ -29,9 +31,9 @@ void initialiseDisplay()
|
|||
break;
|
||||
case 4:
|
||||
display.SSD1306_SETCOMPINS_V = 0x12;
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // initialize with the I2C addr 0x3C (for the 128x32)
|
||||
display.clearDisplay();
|
||||
display.setTextSize(1);
|
||||
|
@ -89,7 +91,7 @@ void updateDisplay()
|
|||
display.print(currentStatus.coolant);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
display.setCursor(0,11);
|
||||
switch(configPage1.display3)
|
||||
{
|
||||
|
@ -134,7 +136,7 @@ void updateDisplay()
|
|||
display.print(currentStatus.coolant);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
display.setCursor(64,0);
|
||||
switch(configPage1.display2)
|
||||
{
|
||||
|
@ -159,7 +161,7 @@ void updateDisplay()
|
|||
display.print(currentStatus.freeRAM);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
display.setCursor(64,11);
|
||||
switch(configPage1.display4)
|
||||
{
|
||||
|
@ -184,10 +186,11 @@ void updateDisplay()
|
|||
display.print(currentStatus.freeRAM);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
int barWidth = ldiv(((unsigned long)currentStatus.RPM * 128), 9000).quot;
|
||||
//int barWidth = map(currentStatus.RPM, 0, 9000, 0, 128);
|
||||
display.fillRect(0, 20, barWidth, 10, 1);
|
||||
|
||||
|
||||
display.display();
|
||||
}
|
||||
#endif
|
|
@ -31,7 +31,7 @@
|
|||
#define BIT_SQUIRT_INJ3 2 //inj3 Squirt
|
||||
#define BIT_SQUIRT_INJ4 3 //inj4 Squirt
|
||||
#define BIT_SQUIRT_DFCO 4 //Decelleration fuel cutoff
|
||||
#define BIT_SQUIRT_BOOSTCUT 5 //Fuel component of MAP based boost cut out
|
||||
#define BIT_SQUIRT_BOOSTCUT 5 //Fuel component of MAP based boost cut out
|
||||
#define BIT_SQUIRT_TOOTHLOG1READY 6 //Used to flag if tooth log 1 is ready
|
||||
#define BIT_SQUIRT_TOOTHLOG2READY 7 //Used to flag if tooth log 2 is ready (Log is not currently used)
|
||||
|
||||
|
@ -43,7 +43,7 @@
|
|||
#define BIT_SPARK_BOOSTCUT 4 //Spark component of MAP based boost cut out
|
||||
#define BIT_SPARK_ERROR 5 // Error is detected
|
||||
#define BIT_SPARK_IDLE 6 // idle on
|
||||
#define BIT_SPARK_SYNC 7 // Whether engine has sync or not
|
||||
#define BIT_SPARK_SYNC 7 // Whether engine has sync or not
|
||||
|
||||
#define BIT_SPARK2_FLATSH 0 //Flat shift hard cut
|
||||
#define BIT_SPARK2_FLATSS 1 //Flat shift soft cut
|
||||
|
@ -91,7 +91,7 @@ const byte signature = 20;
|
|||
const char displaySignature[] = "speeduino 201609-dev";
|
||||
const char TSfirmwareVersion[] = "Speeduino 2016.09";
|
||||
|
||||
const byte data_structure_version = 2; //This identifies the data structure when reading / writing.
|
||||
const byte data_structure_version = 2; //This identifies the data structure when reading / writing.
|
||||
const byte page_size = 64;
|
||||
const int npage_size[11] ={0,288,64,288,64,288,64,64,160,192,128};
|
||||
//const byte page10_size = 128;
|
||||
|
@ -147,7 +147,7 @@ struct statuses {
|
|||
long longRPM;
|
||||
int mapADC;
|
||||
long MAP; //Has to be a long for PID calcs (Boost control)
|
||||
int baro; //Barometric pressure is simply the inital MAP reading, taken before the engine is running
|
||||
byte baro; //Barometric pressure is simply the inital MAP reading, taken before the engine is running
|
||||
byte TPS; //The current TPS reading (0% - 100%)
|
||||
byte TPSlast; //The previous TPS reading
|
||||
unsigned long TPS_time; //The time the TPS sample was taken
|
||||
|
@ -181,7 +181,7 @@ struct statuses {
|
|||
byte afrTarget;
|
||||
byte idleDuty;
|
||||
bool fanOn; //Whether or not the fan is turned on
|
||||
volatile byte ethanolPct; //Ethanol reading (if enabled). 0 = No ethanol, 100 = pure ethanol. Eg E85 = 85.
|
||||
volatile byte ethanolPct; //Ethanol reading (if enabled). 0 = No ethanol, 100 = pure ethanol. Eg E85 = 85.
|
||||
unsigned long TAEEndTime; //The target end time used whenever TAE is turned on
|
||||
volatile byte squirt;
|
||||
volatile byte spark;
|
||||
|
@ -192,28 +192,28 @@ struct statuses {
|
|||
unsigned int PW3; //In uS
|
||||
unsigned int PW4; //In uS
|
||||
volatile byte runSecs; //Counter of seconds since cranking commenced (overflows at 255 obviously)
|
||||
volatile byte secl; //Continous
|
||||
volatile byte secl; //Continous
|
||||
volatile unsigned int loopsPerSecond;
|
||||
boolean launchingSoft; //True when in launch control soft limit mode
|
||||
boolean launchingHard; //True when in launch control hard limit mode
|
||||
int freeRAM;
|
||||
unsigned int clutchEngagedRPM;
|
||||
bool flatShiftingHard;
|
||||
volatile byte startRevolutions = 0; //A counter for how many revolutions have been completed since sync was achieved.
|
||||
|
||||
volatile byte startRevolutions; //A counter for how many revolutions have been completed since sync was achieved.
|
||||
|
||||
//Helpful bitwise operations:
|
||||
//Useful reference: http://playground.arduino.cc/Code/BitMath
|
||||
// y = (x >> n) & 1; // n=0..15. stores nth bit of x in y. y becomes 0 or 1.
|
||||
// x &= ~(1 << n); // forces nth bit of x to be 0. all other bits left alone.
|
||||
// x |= (1 << n); // forces nth bit of x to be 1. all other bits left alone.
|
||||
|
||||
|
||||
};
|
||||
struct statuses currentStatus; //The global status object
|
||||
|
||||
//Page 1 of the config - See the ini file for further reference
|
||||
//This mostly covers off variables that are required for fuel
|
||||
struct config1 {
|
||||
|
||||
|
||||
byte unused1; //Cold cranking pulsewidth modifier. This is added to the fuel pulsewidth when cranking under a certain temp threshold (ms)
|
||||
byte unused2; //Warm cranking pulsewidth modifier. This is added to the fuel pulsewidth when cranking (ms)
|
||||
byte asePct; //Afterstart enrichment (%)
|
||||
|
@ -227,30 +227,31 @@ struct config1 {
|
|||
byte taeColdA;
|
||||
byte tpsThresh;
|
||||
byte taeTime;
|
||||
|
||||
|
||||
//Display config bits
|
||||
byte displayType : 3;
|
||||
byte display1 : 3;
|
||||
byte display2 : 2;
|
||||
|
||||
|
||||
byte display3 : 3;
|
||||
byte display4 : 2;
|
||||
byte display5 : 3;
|
||||
|
||||
|
||||
byte displayB1 : 4;
|
||||
byte displayB2 : 4;
|
||||
|
||||
|
||||
byte reqFuel;
|
||||
byte divider;
|
||||
byte injTiming : 1;
|
||||
byte multiplyMAP : 1;
|
||||
byte includeAFR : 1;
|
||||
byte unused26 : 5;
|
||||
byte unused26 : 4;
|
||||
byte indInjAng : 1;
|
||||
byte injOpen; //Injector opening time (ms * 10)
|
||||
unsigned int inj1Ang;
|
||||
unsigned int inj2Ang;
|
||||
unsigned int inj3Ang;
|
||||
unsigned int inj4Ang;
|
||||
unsigned int inj2Ang;
|
||||
unsigned int inj3Ang;
|
||||
unsigned int inj4Ang;
|
||||
|
||||
//config1 in ini
|
||||
byte mapSample : 2;
|
||||
|
@ -258,21 +259,21 @@ struct config1 {
|
|||
byte injType : 1;
|
||||
byte nCylinders : 4; //Number of cylinders
|
||||
|
||||
//config2 in ini
|
||||
//config2 in ini
|
||||
byte cltType1 : 2;
|
||||
byte matType1 : 2;
|
||||
byte nInjectors : 4; //Number of injectors
|
||||
|
||||
|
||||
|
||||
//config3 in ini
|
||||
byte engineType : 1;
|
||||
byte engineType : 1;
|
||||
byte flexEnabled : 1;
|
||||
byte algorithm : 1; //"Speed Density", "Alpha-N"
|
||||
byte baroCorr : 1;
|
||||
byte injLayout : 2;
|
||||
byte canEnable : 1; //is can interface enabled
|
||||
byte unused2_38h : 1;
|
||||
|
||||
|
||||
byte primePulse;
|
||||
byte dutyLim;
|
||||
byte flexFreqLow; //Lowest valid frequency reading from the flex sensor
|
||||
|
@ -294,18 +295,18 @@ struct config1 {
|
|||
byte unused61;
|
||||
byte unused62;
|
||||
byte unused63;
|
||||
|
||||
|
||||
};
|
||||
|
||||
//Page 2 of the config - See the ini file for further reference
|
||||
//This mostly covers off variables that are required for ignition
|
||||
struct config2 {
|
||||
|
||||
|
||||
int triggerAngle;
|
||||
byte FixAng;
|
||||
byte CrankAng;
|
||||
byte TrigAngMul; //Multiplier for non evenly divisible tooth counts.
|
||||
|
||||
byte TrigAngMul; //Multiplier for non evenly divisible tooth counts.
|
||||
|
||||
byte TrigEdge : 1;
|
||||
byte TrigSpeed : 1;
|
||||
byte IgInv : 1;
|
||||
|
@ -315,22 +316,22 @@ struct config2 {
|
|||
byte TrigEdgeSec : 1;
|
||||
byte fuelPumpPin : 6;
|
||||
byte unused4_6b : 1;
|
||||
|
||||
|
||||
byte unused4_7;
|
||||
byte IdleAdvRPM;
|
||||
byte IdleAdvCLT; //The temperature below which the idle is advanced
|
||||
byte IdleDelayTime;
|
||||
byte StgCycles; //The number of initial cycles before the ignition should fire when first cranking
|
||||
|
||||
|
||||
byte dwellCont : 1; //Fixed duty dwell control
|
||||
byte useDwellLim : 1; //Whether the dwell limiter is off or on
|
||||
byte sparkMode : 2; //Spark output mode (Eg Wasted spark, single channel or Wasted COP)
|
||||
byte dfcoEnabled : 1; //Whether or not DFCO is turned on
|
||||
byte triggerFilter : 2; //The mode of trigger filter being used (0=Off, 1=Light (Not currently used), 2=Normal, 3=Aggressive)
|
||||
byte ignCranklock : 1; //Whether or not the ignition timing during cranking is locked to a CAS pulse. Only currently valid for Basic distributor and 4G63.
|
||||
|
||||
byte ignCranklock : 1; //Whether or not the ignition timing during cranking is locked to a CAS pulse. Only currently valid for Basic distributor and 4G63.
|
||||
|
||||
byte dwellCrank; //Dwell time whilst cranking
|
||||
byte dwellRun; //Dwell time whilst running
|
||||
byte dwellRun; //Dwell time whilst running
|
||||
byte triggerTeeth; //The full count of teeth on the trigger wheel if there were no gaps
|
||||
byte triggerMissingTeeth; //The size of the tooth gap (ie number of missing teeth)
|
||||
byte crankRPM; //RPM below which the engine is considered to be cranking
|
||||
|
@ -352,21 +353,21 @@ struct config2 {
|
|||
|
||||
byte ignBypassEnabled : 1; //Whether or not the ignition bypass is enabled
|
||||
byte ignBypassPin : 6; //Pin the ignition bypass is activated on
|
||||
byte ignBypassHiLo : 1; //Whether this should be active high or low.
|
||||
byte ignBypassHiLo : 1; //Whether this should be active high or low.
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
//Page 3 of the config - See the ini file for further reference
|
||||
//This mostly covers off variables that are required for AFR targets and closed loop
|
||||
struct config3 {
|
||||
|
||||
|
||||
byte egoAlgorithm : 2;
|
||||
byte egoType : 2;
|
||||
byte boostEnabled : 1;
|
||||
byte vvtEnabled : 1;
|
||||
byte boostCutType : 2;
|
||||
|
||||
|
||||
byte egoKP;
|
||||
byte egoKI;
|
||||
byte egoKD;
|
||||
|
@ -379,9 +380,9 @@ struct config3 {
|
|||
byte ego_sdelay; //Time in seconds after engine starts that closed loop becomes available
|
||||
byte egoRPM; //RPM must be above this for closed loop to function
|
||||
byte egoTPSMax; //TPS must be below this for closed loop to function
|
||||
byte boostPin : 6;
|
||||
byte unused6_13 : 2;
|
||||
byte vvtPin : 6;
|
||||
byte unused6_13 : 2;
|
||||
byte boostPin : 6;
|
||||
byte unused6_14 : 2;
|
||||
byte voltageCorrectionBins[6]; //X axis bins for voltage correction tables
|
||||
byte injVoltageCorrectionValues[6]; //Correction table for injector PW vs battery voltage
|
||||
|
@ -390,11 +391,11 @@ struct config3 {
|
|||
byte boostFreq; //Frequency of the boost PWM valve
|
||||
byte vvtFreq; //Frequency of the vvt PWM valve
|
||||
byte idleFreq;
|
||||
|
||||
|
||||
byte launchPin : 6;
|
||||
byte launchEnabled : 1;
|
||||
byte launchHiLo : 1;
|
||||
|
||||
|
||||
byte lnchSoftLim;
|
||||
int8_t lnchRetard; //Allow for negative advance value (ATDC)
|
||||
byte lnchHardLim;
|
||||
|
@ -404,12 +405,12 @@ struct config3 {
|
|||
byte idleKP;
|
||||
byte idleKI;
|
||||
byte idleKD;
|
||||
|
||||
|
||||
byte boostLimit; //Is divided by 2, allowing kPa values up to 511
|
||||
byte boostKP;
|
||||
byte boostKI;
|
||||
byte boostKD;
|
||||
|
||||
|
||||
byte lnchPullRes : 2;
|
||||
byte fuelTrimEnabled : 1;
|
||||
byte flatSEnable : 1;
|
||||
|
@ -418,7 +419,7 @@ struct config3 {
|
|||
byte flatSRetard;
|
||||
byte flatSArm;
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
@ -432,22 +433,22 @@ struct config4 {
|
|||
byte iacCrankSteps[4]; //Steps to use when cranking (Stepper motor)
|
||||
byte iacCrankDuty[4]; //Duty cycle to use on PWM valves when cranking
|
||||
byte iacCrankBins[4]; //Temperature Bins for the above 2 curves
|
||||
|
||||
|
||||
byte iacAlgorithm : 3; //Valid values are: "None", "On/Off", "PWM", "PWM Closed Loop", "Stepper", "Stepper Closed Loop"
|
||||
byte iacStepTime : 3; //How long to pulse the stepper for to ensure the step completes (ms)
|
||||
byte iacChannels : 1; //How many outputs to use in PWM mode (0 = 1 channel, 1 = 2 channels)
|
||||
byte iacPWMdir : 1; //Directino of the PWM valve. 0 = Normal = Higher RPM with more duty. 1 = Reverse = Lower RPM with more duty
|
||||
|
||||
|
||||
byte iacFastTemp; //Fast idle temp when using a simple on/off valve
|
||||
|
||||
|
||||
byte iacStepHome; //When using a stepper motor, the number of steps to be taken on startup to home the motor
|
||||
byte iacStepHyster; //Hysteresis temperature (*10). Eg 2.2C = 22
|
||||
|
||||
|
||||
byte fanInv : 1; // Fan output inversion bit
|
||||
byte fanEnable : 1; // Fan enable bit. 0=Off, 1=On/Off
|
||||
byte fanPin : 5;
|
||||
byte fanSP; // Cooling fan start temperature
|
||||
byte fanHyster; // Fan hysteresis
|
||||
byte fanHyster; // Fan hysteresis
|
||||
byte fanFreq; // Fan PWM frequency
|
||||
byte fanPWMBins[4]; //Temperature Bins for the PWM fan control
|
||||
};
|
|
@ -0,0 +1,7 @@
|
|||
#ifndef MATH_H
|
||||
#define MATH_H
|
||||
|
||||
int fastMap1023toX(unsigned long, int);
|
||||
unsigned long percentage(byte, unsigned long);
|
||||
|
||||
#endif
|
|
@ -1,5 +1,7 @@
|
|||
#include "maths.h"
|
||||
|
||||
#define DIV_ROUND_CLOSEST(n, d) ((((n) < 0) ^ ((d) < 0)) ? (((n) - (d)/2)/(d)) : (((n) + (d)/2)/(d)))
|
||||
|
||||
//Replace the standard arduino map() function to use the div function instead
|
||||
int fastMap(unsigned long x, int in_min, int in_max, int out_min, int out_max)
|
||||
{
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
This scheduler is designed to maintain 2 schedules for use by the fuel and ignition systems.
|
||||
This scheduler is designed to maintain 2 schedules for use by the fuel and ignition systems.
|
||||
It functions by waiting for the overflow vectors from each of the timers in use to overflow, which triggers an interrupt
|
||||
|
||||
//Technical
|
||||
|
@ -25,20 +25,17 @@ See page 136 of the processors datasheet: http://www.atmel.com/Images/doc2549.pd
|
|||
#ifndef SCHEDULER_H
|
||||
#define SCHEDULER_H
|
||||
|
||||
#ifdef __SAM3X8E__
|
||||
//Do stuff for ARM based CPUs
|
||||
#else
|
||||
#include <avr/interrupt.h>
|
||||
#include <avr/io.h>
|
||||
#endif
|
||||
|
||||
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) || defined(__AVR_ATmega2561__)
|
||||
#include <avr/interrupt.h>
|
||||
#include <avr/io.h>
|
||||
|
||||
//Refer to http://svn.savannah.nongnu.org/viewvc/trunk/avr-libc/include/avr/iomxx0_1.h?root=avr-libc&view=markup
|
||||
#define FUEL1_COUNTER TCNT3
|
||||
#define FUEL2_COUNTER TCNT3
|
||||
#define FUEL3_COUNTER TCNT3
|
||||
#define FUEL4_COUNTER TCNT4
|
||||
|
||||
|
||||
#define IGN1_COUNTER TCNT5
|
||||
#define IGN2_COUNTER TCNT5
|
||||
#define IGN3_COUNTER TCNT5
|
||||
|
@ -49,7 +46,7 @@ See page 136 of the processors datasheet: http://www.atmel.com/Images/doc2549.pd
|
|||
#define FUEL2_COMPARE OCR3B
|
||||
#define FUEL3_COMPARE OCR3C
|
||||
#define FUEL4_COMPARE OCR4B
|
||||
|
||||
|
||||
#define IGN1_COMPARE OCR5A
|
||||
#define IGN2_COMPARE OCR5B
|
||||
#define IGN3_COMPARE OCR5C
|
||||
|
@ -72,7 +69,7 @@ See page 136 of the processors datasheet: http://www.atmel.com/Images/doc2549.pd
|
|||
#define IGN4_TIMER_ENABLE() TIMSK4 |= (1 << OCIE4A) //Turn on the A compare unit (ie turn on the interrupt)
|
||||
#define IGN5_TIMER_ENABLE() TIMSK1 |= (1 << OCIE1C) //Turn on the A compare unit (ie turn on the interrupt)
|
||||
|
||||
#define IGN1_TIMER_DISABLE() TIMSK5 &= ~(1 << OCIE5A) //Turn off this output compare unit
|
||||
#define IGN1_TIMER_DISABLE() TIMSK5 &= ~(1 << OCIE5A) //Turn off this output compare unit
|
||||
#define IGN2_TIMER_DISABLE() TIMSK5 &= ~(1 << OCIE5B) //Turn off this output compare unit
|
||||
#define IGN3_TIMER_DISABLE() TIMSK5 &= ~(1 << OCIE5C) //Turn off this output compare unit
|
||||
#define IGN4_TIMER_DISABLE() TIMSK4 &= ~(1 << OCIE4A) //Turn off this output compare unit
|
||||
|
@ -81,7 +78,7 @@ See page 136 of the processors datasheet: http://www.atmel.com/Images/doc2549.pd
|
|||
#define MAX_TIMER_PERIOD 262140 //The longest period of time (in uS) that the timer can permit (IN this case it is 65535 * 4, as each timer tick is 4uS)
|
||||
#define uS_TO_TIMER_COMPARE(uS1) (uS1 >> 2) //Converts a given number of uS into the required number of timer ticks until that time has passed
|
||||
|
||||
#elif defined(CORE_TEENSY)
|
||||
#elif defined(CORE_TEENSY)
|
||||
//http://shawnhymel.com/661/learning-the-teensy-lc-interrupt-service-routines/
|
||||
#define FUEL1_COUNTER FTM0_CNT
|
||||
#define FUEL2_COUNTER FTM0_CNT
|
||||
|
@ -128,7 +125,12 @@ See page 136 of the processors datasheet: http://www.atmel.com/Images/doc2549.pd
|
|||
#define IGN5_TIMER_DISABLE() FTM1_C0SC &= ~FTM_CSC_CHIE
|
||||
|
||||
#define MAX_TIMER_PERIOD 139808 // 2.13333333uS * 65535
|
||||
#define uS_TO_TIMER_COMPARE(uS) ((uS * 15) >> 5) //Converts a given number of uS into the required number of timer ticks until that time has passed.
|
||||
#define uS_TO_TIMER_COMPARE(uS) ((uS * 15) >> 5) //Converts a given number of uS into the required number of timer ticks until that time has passed.
|
||||
|
||||
#elif defined(STM32_MCU_SERIES)
|
||||
//Placeholders ONLY!
|
||||
#define MAX_TIMER_PERIOD 139808 // 2.13333333uS * 65535
|
||||
#define uS_TO_TIMER_COMPARE(uS) ((uS * 15) >> 5) //Converts a given number of uS into the required number of timer ticks until that time has passed.
|
||||
#endif
|
||||
|
||||
void initialiseSchedulers();
|
||||
|
@ -211,18 +213,18 @@ static inline unsigned int setQueue(volatile Schedule *queue[], Schedule *schedu
|
|||
queue[2] = schedule1;
|
||||
queue[3] = schedule1;
|
||||
tmpQueue[2] = schedule1->startCompare - CNT;
|
||||
tmpQueue[3] = schedule1->endCompare - CNT;
|
||||
tmpQueue[3] = schedule1->endCompare - CNT;
|
||||
}
|
||||
else
|
||||
{
|
||||
queue[2] = schedule2;
|
||||
queue[3] = schedule2;
|
||||
queue[3] = schedule2;
|
||||
tmpQueue[2] = schedule2->startCompare - CNT;
|
||||
tmpQueue[3] = schedule2->endCompare - CNT;
|
||||
tmpQueue[3] = schedule2->endCompare - CNT;
|
||||
}
|
||||
|
||||
|
||||
//Sort the queues. Both queues are kept in sync.
|
||||
//Sort the queues. Both queues are kept in sync.
|
||||
//This implementes a sorting networking based on the Bose-Nelson sorting network
|
||||
//See: http://pages.ripco.net/~jgamble/nw.html
|
||||
#define SWAP(x,y) if(tmpQueue[y] < tmpQueue[x]) { unsigned int tmp = tmpQueue[x]; tmpQueue[x] = tmpQueue[y]; tmpQueue[y] = tmp; volatile Schedule *tmpS = queue[x]; queue[x] = queue[y]; queue[y] = tmpS; }
|
||||
|
@ -233,11 +235,11 @@ static inline unsigned int setQueue(volatile Schedule *queue[], Schedule *schedu
|
|||
SWAP(1, 2);
|
||||
|
||||
//Return the next compare time in the queue
|
||||
return tmpQueue[0] + CNT; //Return the
|
||||
return tmpQueue[0] + CNT; //Return the
|
||||
}
|
||||
|
||||
/*
|
||||
* Moves all the Schedules in a queue forward one position.
|
||||
* Moves all the Schedules in a queue forward one position.
|
||||
* The current item (0) is discarded
|
||||
* The final queue slot is set to nullSchedule to indicate that no action should be taken
|
||||
*/
|
|
@ -34,8 +34,8 @@ void initialiseSchedulers()
|
|||
TCNT4 = 0; //Reset Timer Count
|
||||
TIFR4 = 0x00; //Timer4 INT Flag Reg: Clear Timer Overflow Flag
|
||||
TCCR4A = 0x00; //Timer4 Control Reg A: Wave Gen Mode normal
|
||||
TCCR4B = (1 << CS12); //Timer4 Control Reg B: aka Divisor = 256 = 122.5HzTimer Prescaler set to 256. Refer to http://www.instructables.com/files/orig/F3T/TIKL/H3WSA4V7/F3TTIKLH3WSA4V7.jpg
|
||||
|
||||
TCCR4B = (1 << CS12); //Timer4 Control Reg B: aka Divisor = 256 = 122.5HzTimer Prescaler set to 256. Refer to http://www.instructables.com/files/orig/F3T/TIKL/H3WSA4V7/F3TTIKLH3WSA4V7.jpg
|
||||
|
||||
#elif defined (CORE_TEENSY) && defined (__MK20DX256__)
|
||||
|
||||
//FlexTimer 0 is used for 4 ignition and 4 injection schedules. There are 8 channels on this module, so no other timers are needed
|
||||
|
@ -57,23 +57,23 @@ void initialiseSchedulers()
|
|||
FTM1_CNTIN = 0x0000; //Shouldn't be needed, but just in case
|
||||
FTM1_CNT = 0x0000; // Reset the count to zero
|
||||
FTM1_MOD = 0xFFFF; // max modulus = 65535
|
||||
|
||||
|
||||
/*
|
||||
* Enable the clock for FTM0/1
|
||||
* 00 No clock selected. Disables the FTM counter.
|
||||
* 01 System clock
|
||||
* 10 Fixed frequency clock
|
||||
* 11 External clock
|
||||
*/
|
||||
*/
|
||||
FTM0_SC |= FTM_SC_CLKS(0b1);
|
||||
FTM1_SC |= FTM_SC_CLKS(0b1);
|
||||
|
||||
/*
|
||||
* Set Prescaler
|
||||
/*
|
||||
* Set Prescaler
|
||||
* This is the slowest that the timer can be clocked (Without used the slow timer, which is too slow). It results in ticks of 2.13333uS on the teensy 3.5:
|
||||
* 60000000 Hz = F_BUS
|
||||
* 128 * 1000000uS / F_BUS = 2.133uS
|
||||
*
|
||||
*
|
||||
* 000 = Divide by 1
|
||||
* 001 Divide by 2
|
||||
* 010 Divide by 4
|
||||
|
@ -86,38 +86,38 @@ void initialiseSchedulers()
|
|||
FTM0_SC |= FTM_SC_PS(0b111);
|
||||
FTM1_SC |= FTM_SC_PS(0b111);
|
||||
|
||||
//Setup the channels (See Pg 1014 of K64 DS).
|
||||
//Setup the channels (See Pg 1014 of K64 DS).
|
||||
//FTM0_C0SC &= ~FTM_CSC_ELSB; //Probably not needed as power on state should be 0
|
||||
//FTM0_C0SC &= ~FTM_CSC_ELSA; //Probably not needed as power on state should be 0
|
||||
//FTM0_C0SC &= ~FTM_CSC_DMA; //Probably not needed as power on state should be 0
|
||||
FTM0_C0SC &= ~FTM_CSC_MSB; //According to Pg 965 of the K64 datasheet, this should not be needed as MSB is reset to 0 upon reset, but the channel interrupt fails to fire without it
|
||||
FTM0_C0SC |= FTM_CSC_MSA; //Enable Compare mode
|
||||
FTM0_C0SC |= FTM_CSC_CHIE; //Enable channel compare interrupt
|
||||
|
||||
|
||||
FTM0_C1SC &= ~FTM_CSC_MSB; //According to Pg 965 of the datasheet, this should not be needed as MSB is reset to 0 upon reset, but the channel interrupt fails to fire without it
|
||||
FTM0_C1SC |= FTM_CSC_MSA; //Enable Compare mode
|
||||
FTM0_C1SC |= FTM_CSC_CHIE; //Enable channel compare interrupt
|
||||
|
||||
|
||||
FTM0_C2SC &= ~FTM_CSC_MSB; //According to Pg 965 of the datasheet, this should not be needed as MSB is reset to 0 upon reset, but the channel interrupt fails to fire without it
|
||||
FTM0_C2SC |= FTM_CSC_MSA; //Enable Compare mode
|
||||
FTM0_C2SC |= FTM_CSC_CHIE; //Enable channel compare interrupt
|
||||
|
||||
|
||||
FTM0_C3SC &= ~FTM_CSC_MSB; //According to Pg 965 of the datasheet, this should not be needed as MSB is reset to 0 upon reset, but the channel interrupt fails to fire without it
|
||||
FTM0_C3SC |= FTM_CSC_MSA; //Enable Compare mode
|
||||
FTM0_C3SC |= FTM_CSC_CHIE; //Enable channel compare interrupt
|
||||
|
||||
|
||||
FTM0_C4SC &= ~FTM_CSC_MSB; //According to Pg 965 of the datasheet, this should not be needed as MSB is reset to 0 upon reset, but the channel interrupt fails to fire without it
|
||||
FTM0_C4SC |= FTM_CSC_MSA; //Enable Compare mode
|
||||
FTM0_C4SC |= FTM_CSC_CHIE; //Enable channel compare interrupt
|
||||
|
||||
|
||||
FTM0_C5SC &= ~FTM_CSC_MSB; //According to Pg 965 of the datasheet, this should not be needed as MSB is reset to 0 upon reset, but the channel interrupt fails to fire without it
|
||||
FTM0_C5SC |= FTM_CSC_MSA; //Enable Compare mode
|
||||
FTM0_C5SC |= FTM_CSC_CHIE; //Enable channel compare interrupt
|
||||
|
||||
|
||||
FTM0_C6SC &= ~FTM_CSC_MSB; //According to Pg 965 of the datasheet, this should not be needed as MSB is reset to 0 upon reset, but the channel interrupt fails to fire without it
|
||||
FTM0_C6SC |= FTM_CSC_MSA; //Enable Compare mode
|
||||
FTM0_C6SC |= FTM_CSC_CHIE; //Enable channel compare interrupt
|
||||
|
||||
|
||||
FTM0_C7SC &= ~FTM_CSC_MSB; //According to Pg 965 of the datasheet, this should not be needed as MSB is reset to 0 upon reset, but the channel interrupt fails to fire without it
|
||||
FTM0_C7SC |= FTM_CSC_MSA; //Enable Compare mode
|
||||
FTM0_C7SC |= FTM_CSC_CHIE; //Enable channel compare interrupt
|
||||
|
@ -130,10 +130,10 @@ void initialiseSchedulers()
|
|||
// enable IRQ Interrupt
|
||||
NVIC_ENABLE_IRQ(IRQ_FTM0);
|
||||
NVIC_ENABLE_IRQ(IRQ_FTM1);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
fuelSchedule1.Status = OFF;
|
||||
fuelSchedule1.Status = OFF;
|
||||
fuelSchedule2.Status = OFF;
|
||||
fuelSchedule3.Status = OFF;
|
||||
fuelSchedule4.Status = OFF;
|
||||
|
@ -150,15 +150,15 @@ void initialiseSchedulers()
|
|||
ignitionSchedule3.Status = OFF;
|
||||
ignitionSchedule4.Status = OFF;
|
||||
ignitionSchedule5.Status = OFF;
|
||||
|
||||
|
||||
ignitionSchedule1.schedulesSet = 0;
|
||||
ignitionSchedule2.schedulesSet = 0;
|
||||
ignitionSchedule3.schedulesSet = 0;
|
||||
ignitionSchedule4.schedulesSet = 0;
|
||||
ignitionSchedule5.schedulesSet = 0;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
These 8 function turn a schedule on, provides the time to start and the duration and gives it callback functions.
|
||||
All 8 functions operate the same, just on different schedules
|
||||
|
@ -171,7 +171,7 @@ endCallback: This function is called once the duration time has been reached
|
|||
void setFuelSchedule1(void (*startCallback)(), unsigned long timeout, unsigned long duration, void(*endCallback)())
|
||||
{
|
||||
if(fuelSchedule1.Status == RUNNING) { return; } //Check that we're not already part way through a schedule
|
||||
|
||||
|
||||
fuelSchedule1.StartCallback = startCallback; //Name the start callback function
|
||||
fuelSchedule1.EndCallback = endCallback; //Name the end callback function
|
||||
fuelSchedule1.duration = duration;
|
||||
|
@ -179,7 +179,7 @@ void setFuelSchedule1(void (*startCallback)(), unsigned long timeout, unsigned l
|
|||
/*
|
||||
* The following must be enclosed in the noInterupts block to avoid contention caused if the relevant interrupts fires before the state is fully set
|
||||
* We need to calculate the value to reset the timer to (preload) in order to achieve the desired overflow time
|
||||
* As the timer is ticking every 16uS (Time per Tick = (Prescale)*(1/Frequency))
|
||||
* As the timer is ticking every 16uS (Time per Tick = (Prescale)*(1/Frequency))
|
||||
* unsigned int absoluteTimeout = TCNT3 + (timeout / 16); //Each tick occurs every 16uS with the 256 prescaler, so divide the timeout by 16 to get ther required number of ticks. Add this to the current tick count to get the target time. This will automatically overflow as required
|
||||
*/
|
||||
noInterrupts();
|
||||
|
@ -196,7 +196,7 @@ void setFuelSchedule1(void (*startCallback)(), unsigned long timeout, unsigned l
|
|||
void setFuelSchedule2(void (*startCallback)(), unsigned long timeout, unsigned long duration, void(*endCallback)())
|
||||
{
|
||||
if(fuelSchedule2.Status == RUNNING) { return; } //Check that we're not already part way through a schedule
|
||||
|
||||
|
||||
fuelSchedule2.StartCallback = startCallback; //Name the start callback function
|
||||
fuelSchedule2.EndCallback = endCallback; //Name the end callback function
|
||||
fuelSchedule2.duration = duration;
|
||||
|
@ -204,7 +204,7 @@ void setFuelSchedule2(void (*startCallback)(), unsigned long timeout, unsigned l
|
|||
/*
|
||||
* The following must be enclosed in the noIntterupts block to avoid contention caused if the relevant interrupts fires before the state is fully set
|
||||
* We need to calculate the value to reset the timer to (preload) in order to achieve the desired overflow time
|
||||
* As the timer is ticking every 16uS (Time per Tick = (Prescale)*(1/Frequency))
|
||||
* As the timer is ticking every 16uS (Time per Tick = (Prescale)*(1/Frequency))
|
||||
* unsigned int absoluteTimeout = TCNT3 + (timeout / 16); //Each tick occurs every 16uS with the 256 prescaler, so divide the timeout by 16 to get ther required number of ticks. Add this to the current tick count to get the target time. This will automatically overflow as required
|
||||
*/
|
||||
noInterrupts();
|
||||
|
@ -223,11 +223,11 @@ void setFuelSchedule3(void (*startCallback)(), unsigned long timeout, unsigned l
|
|||
fuelSchedule3.StartCallback = startCallback; //Name the start callback function
|
||||
fuelSchedule3.EndCallback = endCallback; //Name the end callback function
|
||||
fuelSchedule3.duration = duration;
|
||||
|
||||
|
||||
/*
|
||||
* The following must be enclosed in the noIntterupts block to avoid contention caused if the relevant interrupts fires before the state is fully set
|
||||
* We need to calculate the value to reset the timer to (preload) in order to achieve the desired overflow time
|
||||
* As the timer is ticking every 16uS (Time per Tick = (Prescale)*(1/Frequency))
|
||||
* As the timer is ticking every 16uS (Time per Tick = (Prescale)*(1/Frequency))
|
||||
* unsigned int absoluteTimeout = TCNT3 + (timeout / 16); //Each tick occurs every 16uS with the 256 prescaler, so divide the timeout by 16 to get ther required number of ticks. Add this to the current tick count to get the target time. This will automatically overflow as required
|
||||
*/
|
||||
noInterrupts();
|
||||
|
@ -242,15 +242,15 @@ void setFuelSchedule3(void (*startCallback)(), unsigned long timeout, unsigned l
|
|||
void setFuelSchedule4(void (*startCallback)(), unsigned long timeout, unsigned long duration, void(*endCallback)()) //Uses timer 4 compare B
|
||||
{
|
||||
if(fuelSchedule4.Status == RUNNING) { return; } //Check that we're not already part way through a schedule
|
||||
|
||||
|
||||
fuelSchedule4.StartCallback = startCallback; //Name the start callback function
|
||||
fuelSchedule4.EndCallback = endCallback; //Name the end callback function
|
||||
fuelSchedule4.duration = duration;
|
||||
|
||||
|
||||
/*
|
||||
* The following must be enclosed in the noIntterupts block to avoid contention caused if the relevant interrupts fires before the state is fully set
|
||||
* We need to calculate the value to reset the timer to (preload) in order to achieve the desired overflow time
|
||||
* As the timer is ticking every 16uS (Time per Tick = (Prescale)*(1/Frequency))
|
||||
* As the timer is ticking every 16uS (Time per Tick = (Prescale)*(1/Frequency))
|
||||
* unsigned int absoluteTimeout = TCNT3 + (timeout / 16); //Each tick occurs every 16uS with the 256 prescaler, so divide the timeout by 16 to get ther required number of ticks. Add this to the current tick count to get the target time. This will automatically overflow as required
|
||||
*/
|
||||
noInterrupts();
|
||||
|
@ -265,9 +265,9 @@ void setFuelSchedule4(void (*startCallback)(), unsigned long timeout, unsigned l
|
|||
void setFuelSchedule5(void (*startCallback)(), unsigned long timeout, unsigned long duration, void(*endCallback)())
|
||||
{
|
||||
if(fuelSchedule5.Status == RUNNING) { return; } //Check that we're not already part way through a schedule
|
||||
|
||||
|
||||
//We need to calculate the value to reset the timer to (preload) in order to achieve the desired overflow time
|
||||
//As the timer is ticking every 16uS (Time per Tick = (Prescale)*(1/Frequency))
|
||||
//As the timer is ticking every 16uS (Time per Tick = (Prescale)*(1/Frequency))
|
||||
//unsigned int absoluteTimeout = TCNT3 + (timeout / 16); //Each tick occurs every 16uS with the 256 prescaler, so divide the timeout by 16 to get ther required number of ticks. Add this to the current tick count to get the target time. This will automatically overflow as required
|
||||
fuelSchedule5.StartCallback = startCallback; //Name the start callback function
|
||||
fuelSchedule5.EndCallback = endCallback; //Name the end callback function
|
||||
|
@ -295,8 +295,8 @@ void setIgnitionSchedule1(void (*startCallback)(), unsigned long timeout, unsign
|
|||
ignitionSchedule1.StartCallback = startCallback; //Name the start callback function
|
||||
ignitionSchedule1.EndCallback = endCallback; //Name the start callback function
|
||||
ignitionSchedule1.duration = duration;
|
||||
|
||||
//As the timer is ticking every 4uS (Time per Tick = (Prescale)*(1/Frequency))
|
||||
|
||||
//As the timer is ticking every 4uS (Time per Tick = (Prescale)*(1/Frequency))
|
||||
if (timeout > MAX_TIMER_PERIOD) { timeout = MAX_TIMER_PERIOD - 1; } // If the timeout is >4x (Each tick represents 4uS) the maximum allowed value of unsigned int (65535), the timer compare value will overflow when appliedcausing erratic behaviour such as erroneous sparking.
|
||||
|
||||
noInterrupts();
|
||||
|
@ -311,14 +311,14 @@ void setIgnitionSchedule1(void (*startCallback)(), unsigned long timeout, unsign
|
|||
void setIgnitionSchedule2(void (*startCallback)(), unsigned long timeout, unsigned long duration, void(*endCallback)())
|
||||
{
|
||||
if(ignitionSchedule2.Status == RUNNING) { return; } //Check that we're not already part way through a schedule
|
||||
|
||||
|
||||
ignitionSchedule2.StartCallback = startCallback; //Name the start callback function
|
||||
ignitionSchedule2.EndCallback = endCallback; //Name the start callback function
|
||||
ignitionSchedule2.duration = duration;
|
||||
|
||||
//As the timer is ticking every 4uS (Time per Tick = (Prescale)*(1/Frequency))
|
||||
|
||||
//As the timer is ticking every 4uS (Time per Tick = (Prescale)*(1/Frequency))
|
||||
if (timeout > MAX_TIMER_PERIOD) { timeout = MAX_TIMER_PERIOD - 1; } // If the timeout is >4x (Each tick represents 4uS) the maximum allowed value of unsigned int (65535), the timer compare value will overflow when appliedcausing erratic behaviour such as erroneous sparking.
|
||||
|
||||
|
||||
noInterrupts();
|
||||
ignitionSchedule2.startCompare = IGN2_COUNTER + uS_TO_TIMER_COMPARE(timeout); //As there is a tick every 4uS, there are timeout/4 ticks until the interrupt should be triggered ( >>2 divides by 4)
|
||||
ignitionSchedule2.endCompare = ignitionSchedule2.startCompare + uS_TO_TIMER_COMPARE(duration);
|
||||
|
@ -335,10 +335,10 @@ void setIgnitionSchedule3(void (*startCallback)(), unsigned long timeout, unsign
|
|||
ignitionSchedule3.StartCallback = startCallback; //Name the start callback function
|
||||
ignitionSchedule3.EndCallback = endCallback; //Name the start callback function
|
||||
ignitionSchedule3.duration = duration;
|
||||
|
||||
//The timer is ticking every 4uS (Time per Tick = (Prescale)*(1/Frequency))
|
||||
|
||||
//The timer is ticking every 4uS (Time per Tick = (Prescale)*(1/Frequency))
|
||||
if (timeout > MAX_TIMER_PERIOD) { timeout = MAX_TIMER_PERIOD - 1; } // If the timeout is >4x (Each tick represents 4uS) the maximum allowed value of unsigned int (65535), the timer compare value will overflow when appliedcausing erratic behaviour such as erroneous sparking.
|
||||
|
||||
|
||||
noInterrupts();
|
||||
ignitionSchedule3.startCompare = IGN3_COUNTER + uS_TO_TIMER_COMPARE(timeout); //As there is a tick every 4uS, there are timeout/4 ticks until the interrupt should be triggered ( >>2 divides by 4)
|
||||
ignitionSchedule3.endCompare = ignitionSchedule3.startCompare + uS_TO_TIMER_COMPARE(duration);
|
||||
|
@ -346,7 +346,7 @@ void setIgnitionSchedule3(void (*startCallback)(), unsigned long timeout, unsign
|
|||
ignitionSchedule3.Status = PENDING; //Turn this schedule on
|
||||
ignitionSchedule3.schedulesSet++;
|
||||
interrupts();
|
||||
IGN3_TIMER_ENABLE();
|
||||
IGN3_TIMER_ENABLE();
|
||||
}
|
||||
void setIgnitionSchedule4(void (*startCallback)(), unsigned long timeout, unsigned long duration, void(*endCallback)())
|
||||
{
|
||||
|
@ -355,7 +355,7 @@ void setIgnitionSchedule4(void (*startCallback)(), unsigned long timeout, unsign
|
|||
ignitionSchedule4.StartCallback = startCallback; //Name the start callback function
|
||||
ignitionSchedule4.EndCallback = endCallback; //Name the start callback function
|
||||
ignitionSchedule4.duration = duration;
|
||||
|
||||
|
||||
//We need to calculate the value to reset the timer to (preload) in order to achieve the desired overflow time
|
||||
//The timer is ticking every 16uS (Time per Tick = (Prescale)*(1/Frequency))
|
||||
//Note this is different to the other ignition timers
|
||||
|
@ -368,7 +368,7 @@ void setIgnitionSchedule4(void (*startCallback)(), unsigned long timeout, unsign
|
|||
ignitionSchedule4.Status = PENDING; //Turn this schedule on
|
||||
ignitionSchedule4.schedulesSet++;
|
||||
interrupts();
|
||||
IGN4_TIMER_ENABLE();
|
||||
IGN4_TIMER_ENABLE();
|
||||
}
|
||||
void setIgnitionSchedule5(void (*startCallback)(), unsigned long timeout, unsigned long duration, void(*endCallback)())
|
||||
{
|
||||
|
@ -377,7 +377,7 @@ void setIgnitionSchedule5(void (*startCallback)(), unsigned long timeout, unsign
|
|||
ignitionSchedule5.StartCallback = startCallback; //Name the start callback function
|
||||
ignitionSchedule5.EndCallback = endCallback; //Name the start callback function
|
||||
ignitionSchedule5.duration = duration;
|
||||
|
||||
|
||||
//We need to calculate the value to reset the timer to (preload) in order to achieve the desired overflow time
|
||||
//The timer is ticking every 16uS (Time per Tick = (Prescale)*(1/Frequency))
|
||||
//Note this is different to the other ignition timers
|
||||
|
@ -390,9 +390,9 @@ void setIgnitionSchedule5(void (*startCallback)(), unsigned long timeout, unsign
|
|||
ignitionSchedule5.Status = PENDING; //Turn this schedule on
|
||||
ignitionSchedule5.schedulesSet++;
|
||||
interrupts();
|
||||
IGN5_TIMER_ENABLE();
|
||||
IGN5_TIMER_ENABLE();
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************************************************************************************************************************************************/
|
||||
//This function (All 8 ISR functions that are below) gets called when either the start time or the duration time are reached
|
||||
//This calls the relevant callback function (startCallback or endCallback) depending on the status of the schedule.
|
||||
|
@ -461,7 +461,7 @@ static inline void fuelSchedule3Interrupt() //Most ARM chips can simply call a f
|
|||
FUEL3_TIMER_DISABLE();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) || defined(__AVR_ATmega2561__) //AVR chips use the ISR for this
|
||||
ISR(TIMER4_COMPB_vect, ISR_NOBLOCK) //fuelSchedule4
|
||||
#elif defined (CORE_TEENSY)
|
||||
|
@ -479,10 +479,10 @@ static inline void fuelSchedule4Interrupt() //Most ARM chips can simply call a f
|
|||
fuelSchedule4.EndCallback();
|
||||
fuelSchedule4.Status = OFF; //Turn off the schedule
|
||||
fuelSchedule4.schedulesSet = 0;
|
||||
FUEL4_TIMER_DISABLE();
|
||||
FUEL4_TIMER_DISABLE();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) || defined(__AVR_ATmega2561__) //AVR chips use the ISR for this
|
||||
ISR(TIMER5_COMPA_vect) //ignitionSchedule1
|
||||
#elif defined (CORE_TEENSY)
|
||||
|
@ -506,7 +506,7 @@ static inline void ignitionSchedule1Interrupt() //Most ARM chips can simply call
|
|||
IGN1_TIMER_DISABLE();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) || defined(__AVR_ATmega2561__) //AVR chips use the ISR for this
|
||||
ISR(TIMER5_COMPB_vect) //ignitionSchedule2
|
||||
#elif defined (CORE_TEENSY)
|
||||
|
@ -530,7 +530,7 @@ static inline void ignitionSchedule2Interrupt() //Most ARM chips can simply call
|
|||
IGN2_TIMER_DISABLE();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) || defined(__AVR_ATmega2561__) //AVR chips use the ISR for this
|
||||
ISR(TIMER5_COMPC_vect) //ignitionSchedule3
|
||||
#elif defined (CORE_TEENSY)
|
||||
|
@ -554,7 +554,7 @@ static inline void ignitionSchedule3Interrupt() //Most ARM chips can simply call
|
|||
IGN3_TIMER_DISABLE();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) || defined(__AVR_ATmega2561__) //AVR chips use the ISR for this
|
||||
ISR(TIMER4_COMPA_vect) //ignitionSchedule4
|
||||
#elif defined (CORE_TEENSY)
|
||||
|
@ -603,16 +603,16 @@ static inline void ignitionSchedule5Interrupt() //Most ARM chips can simply call
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#if defined(CORE_TEENSY)
|
||||
void ftm0_isr(void)
|
||||
void ftm0_isr(void)
|
||||
{
|
||||
|
||||
if(FTM0_C0SC & FTM_CSC_CHF) { FTM0_C0SC &= ~FTM_CSC_CHF; fuelSchedule1Interrupt(); }
|
||||
else if(FTM0_C1SC & FTM_CSC_CHF) { FTM0_C1SC &= ~FTM_CSC_CHF; fuelSchedule2Interrupt(); }
|
||||
else if(FTM0_C2SC & FTM_CSC_CHF) { FTM0_C2SC &= ~FTM_CSC_CHF; fuelSchedule3Interrupt(); }
|
||||
else if(FTM0_C3SC & FTM_CSC_CHF) { FTM0_C3SC &= ~FTM_CSC_CHF; fuelSchedule4Interrupt(); }
|
||||
|
||||
if(FTM0_C0SC & FTM_CSC_CHF) { FTM0_C0SC &= ~FTM_CSC_CHF; fuelSchedule1Interrupt(); }
|
||||
else if(FTM0_C1SC & FTM_CSC_CHF) { FTM0_C1SC &= ~FTM_CSC_CHF; fuelSchedule2Interrupt(); }
|
||||
else if(FTM0_C2SC & FTM_CSC_CHF) { FTM0_C2SC &= ~FTM_CSC_CHF; fuelSchedule3Interrupt(); }
|
||||
else if(FTM0_C3SC & FTM_CSC_CHF) { FTM0_C3SC &= ~FTM_CSC_CHF; fuelSchedule4Interrupt(); }
|
||||
else if(FTM0_C4SC & FTM_CSC_CHF) { FTM0_C4SC &= ~FTM_CSC_CHF; ignitionSchedule1Interrupt(); }
|
||||
else if(FTM0_C5SC & FTM_CSC_CHF) { FTM0_C5SC &= ~FTM_CSC_CHF; ignitionSchedule2Interrupt(); }
|
||||
else if(FTM0_C6SC & FTM_CSC_CHF) { FTM0_C6SC &= ~FTM_CSC_CHF; ignitionSchedule3Interrupt(); }
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef SENSORS_H
|
||||
#define SENSORS_H
|
||||
|
||||
// The following are alpha values for the ADC filters.
|
||||
// The following are alpha values for the ADC filters.
|
||||
// Their values are from 0 to 255 with 0 being no filtering and 255 being maximum
|
||||
#define ADCFILTER_TPS 128
|
||||
#define ADCFILTER_CLT 180
|
||||
|
@ -21,12 +21,12 @@ volatile int AnChannel[15];
|
|||
|
||||
unsigned long MAPrunningValue; //Used for tracking either the total of all MAP readings in this cycle (Event average) or the lowest value detected in this cycle (event minimum)
|
||||
unsigned int MAPcount; //Number of samples taken in the current MAP cycle
|
||||
byte MAPcurRev = 0; //Tracks which revolution we're sampling on
|
||||
byte MAPcurRev; //Tracks which revolution we're sampling on
|
||||
|
||||
/*
|
||||
* Simple low pass IIR filter macro for the analog inputs
|
||||
* This is effectively implementing the smooth filter from http://playground.arduino.cc/Main/Smooth
|
||||
* But removes the use of floats and uses 8 bits of fixed precision.
|
||||
* But removes the use of floats and uses 8 bits of fixed precision.
|
||||
*/
|
||||
#define ADC_FILTER(input, alpha, prior) (((long)input * (256 - alpha) + ((long)prior * alpha))) >> 8
|
||||
|
||||
|
@ -45,7 +45,7 @@ ISR(ADC_vect)
|
|||
|
||||
//ADCSRA = 0x6E; // ADC disabled by clearing bit 7(ADEN)
|
||||
//BIT_CLEAR(ADCSRA, ADIE);
|
||||
|
||||
|
||||
nChannel = ADMUX & 0x07;
|
||||
#if defined(__AVR_ATmega1281__) || defined(__AVR_ATmega2561__)
|
||||
if (nChannel==7) { ADMUX = 0x40; }
|
||||
|
@ -57,7 +57,7 @@ ISR(ADC_vect)
|
|||
ADCSRB = 0x00; //clear MUX5 bit
|
||||
}
|
||||
else if (nChannel == 7) //channel 7
|
||||
{
|
||||
{
|
||||
ADMUX = 0x40;
|
||||
ADCSRB = 0x08; //Set MUX5 bit
|
||||
}
|
|
@ -14,7 +14,7 @@ void initialiseADC()
|
|||
//the code on ISR run each conversion every 25 ADC clock, conversion run about 100KHz effectively
|
||||
//making a 6250 conversions/s on 16 channels and 12500 on 8 channels devices.
|
||||
noInterrupts(); //Interrupts should be turned off when playing with any of these registers
|
||||
|
||||
|
||||
ADCSRB = 0x00; //ADC Auto Trigger Source is in Free Running mode
|
||||
ADMUX = 0x40; //Select AREF as reference, ADC Left Adjust Result, Starting at channel 0
|
||||
|
||||
|
@ -28,12 +28,12 @@ void initialiseADC()
|
|||
BIT_SET(ADCSRA,ADPS2);
|
||||
BIT_SET(ADCSRA,ADPS1);
|
||||
BIT_SET(ADCSRA,ADPS0);
|
||||
|
||||
|
||||
BIT_SET(ADCSRA,ADEN); //Enable ADC
|
||||
|
||||
|
||||
interrupts();
|
||||
BIT_SET(ADCSRA,ADSC); //Start conversion
|
||||
|
||||
|
||||
#else
|
||||
//This sets the ADC (Analog to Digitial Converter) to run at 1Mhz, greatly reducing analog read times (MAP/TPS) when using the standard analogRead() function
|
||||
//1Mhz is the fastest speed permitted by the CPU without affecting accuracy
|
||||
|
@ -42,22 +42,24 @@ void initialiseADC()
|
|||
BIT_CLEAR(ADCSRA,ADPS1);
|
||||
BIT_CLEAR(ADCSRA,ADPS0);
|
||||
#endif
|
||||
MAPcurRev = 0;
|
||||
MAPcount = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
void instanteneousMAPReading()
|
||||
{
|
||||
//Instantaneous MAP readings
|
||||
#if defined(ANALOG_ISR)
|
||||
#if defined(ANALOG_ISR)
|
||||
tempReading = AnChannel[pinMAP-A0];
|
||||
#else
|
||||
tempReading = analogRead(pinMAP);
|
||||
tempReading = analogRead(pinMAP);
|
||||
#endif
|
||||
#endif
|
||||
//Error checking
|
||||
if(tempReading >= VALID_MAP_MAX || tempReading <= VALID_MAP_MIN) { mapErrorCount += 1; }
|
||||
else { currentStatus.mapADC = tempReading; mapErrorCount = 0; }
|
||||
|
||||
|
||||
currentStatus.MAP = fastMap1023toX(currentStatus.mapADC, configPage1.mapMax); //Get the current MAP value
|
||||
}
|
||||
|
||||
|
@ -70,21 +72,21 @@ void readMAP()
|
|||
//Instantaneous MAP readings
|
||||
instanteneousMAPReading();
|
||||
break;
|
||||
|
||||
|
||||
case 1:
|
||||
//Average of a cycle
|
||||
|
||||
if (currentStatus.RPM < 1) { instanteneousMAPReading(); return; } //If the engine isn't running, fall back to instantaneous reads
|
||||
|
||||
if( (MAPcurRev == currentStatus.startRevolutions) || (MAPcurRev == currentStatus.startRevolutions+1) ) //2 revolutions are looked at for 4 stroke. 2 stroke not currently catered for.
|
||||
|
||||
if (currentStatus.RPM < 1 || !currentStatus.hasSync) { instanteneousMAPReading(); return; } //If the engine isn't running, fall back to instantaneous reads
|
||||
|
||||
if( (MAPcurRev == currentStatus.startRevolutions) || (MAPcurRev == currentStatus.startRevolutions+1) ) //2 revolutions are looked at for 4 stroke. 2 stroke not currently catered for.
|
||||
{
|
||||
#if defined(ANALOG_ISR)
|
||||
#if defined(ANALOG_ISR)
|
||||
tempReading = AnChannel[pinMAP-A0];
|
||||
#else
|
||||
tempReading = analogRead(pinMAP);
|
||||
tempReading = analogRead(pinMAP);
|
||||
#endif
|
||||
|
||||
|
||||
//Error check
|
||||
if(tempReading < VALID_MAP_MAX && tempReading > VALID_MAP_MIN)
|
||||
{
|
||||
|
@ -96,6 +98,10 @@ void readMAP()
|
|||
else
|
||||
{
|
||||
//Reaching here means that the last cylce has completed and the MAP value should be calculated
|
||||
|
||||
//Sanity check
|
||||
if (MAPrunningValue == 0 || MAPcount == 0) { instanteneousMAPReading(); return; }
|
||||
|
||||
currentStatus.mapADC = ldiv(MAPrunningValue, MAPcount).quot;
|
||||
currentStatus.MAP = fastMap1023toX(currentStatus.mapADC, configPage1.mapMax); //Get the current MAP value
|
||||
MAPcurRev = currentStatus.startRevolutions; //Reset the current rev count
|
||||
|
@ -103,14 +109,14 @@ void readMAP()
|
|||
MAPcount = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case 2:
|
||||
//Minimum reading in a cycle
|
||||
if (currentStatus.RPM < 1) { instanteneousMAPReading(); return; } //If the engine isn't running, fall back to instantaneous reads
|
||||
|
||||
if( (MAPcurRev == currentStatus.startRevolutions) || (MAPcurRev == currentStatus.startRevolutions+1) ) //2 revolutions are looked at for 4 stroke. 2 stroke not currently catered for.
|
||||
|
||||
if( (MAPcurRev == currentStatus.startRevolutions) || (MAPcurRev == currentStatus.startRevolutions+1) ) //2 revolutions are looked at for 4 stroke. 2 stroke not currently catered for.
|
||||
{
|
||||
#if defined(ANALOG_ISR)
|
||||
#if defined(ANALOG_ISR)
|
||||
tempReading = AnChannel[pinMAP-A0];
|
||||
#else
|
||||
tempReading = analogRead(pinMAP);
|
||||
|
@ -139,24 +145,24 @@ void readTPS()
|
|||
{
|
||||
currentStatus.TPSlast = currentStatus.TPS;
|
||||
currentStatus.TPSlast_time = currentStatus.TPS_time;
|
||||
#if defined(ANALOG_ISR)
|
||||
#if defined(ANALOG_ISR)
|
||||
byte tempTPS = fastMap1023toX(AnChannel[pinTPS-A0], 255); //Get the current raw TPS ADC value and map it into a byte
|
||||
#else
|
||||
analogRead(pinTPS);
|
||||
byte tempTPS = fastMap1023toX(analogRead(pinTPS), 255); //Get the current raw TPS ADC value and map it into a byte
|
||||
#endif
|
||||
currentStatus.tpsADC = ADC_FILTER(tempTPS, ADCFILTER_TPS, currentStatus.tpsADC);
|
||||
//Check that the ADC values fall within the min and max ranges (Should always be the case, but noise can cause these to fluctuate outside the defined range).
|
||||
//Check that the ADC values fall within the min and max ranges (Should always be the case, but noise can cause these to fluctuate outside the defined range).
|
||||
byte tempADC = currentStatus.tpsADC; //The tempADC value is used in order to allow TunerStudio to recover and redo the TPS calibration if this somehow gets corrupted
|
||||
if (currentStatus.tpsADC < configPage1.tpsMin) { tempADC = configPage1.tpsMin; }
|
||||
else if(currentStatus.tpsADC > configPage1.tpsMax) { tempADC = configPage1.tpsMax; }
|
||||
currentStatus.TPS = map(tempADC, configPage1.tpsMin, configPage1.tpsMax, 0, 100); //Take the raw TPS ADC value and convert it into a TPS% based on the calibrated values
|
||||
currentStatus.TPS_time = currentLoopTime;
|
||||
currentStatus.TPS_time = currentLoopTime;
|
||||
}
|
||||
|
||||
void readCLT()
|
||||
{
|
||||
#if defined(ANALOG_ISR)
|
||||
#if defined(ANALOG_ISR)
|
||||
tempReading = fastMap1023toX(AnChannel[pinCLT-A0], 511); //Get the current raw CLT value
|
||||
#else
|
||||
tempReading = analogRead(pinCLT);
|
||||
|
@ -168,7 +174,7 @@ void readCLT()
|
|||
|
||||
void readIAT()
|
||||
{
|
||||
#if defined(ANALOG_ISR)
|
||||
#if defined(ANALOG_ISR)
|
||||
tempReading = fastMap1023toX(AnChannel[pinIAT-A0], 511); //Get the current raw IAT value
|
||||
#else
|
||||
tempReading = analogRead(pinIAT);
|
||||
|
@ -180,16 +186,16 @@ void readIAT()
|
|||
|
||||
void readO2()
|
||||
{
|
||||
#if defined(ANALOG_ISR)
|
||||
tempReading = fastMap1023toX(AnChannel[pinO2-A0], 511); //Get the current O2 value.
|
||||
#if defined(ANALOG_ISR)
|
||||
tempReading = fastMap1023toX(AnChannel[pinO2-A0], 511); //Get the current O2 value.
|
||||
#else
|
||||
tempReading = analogRead(pinO2);
|
||||
tempReading = fastMap1023toX(analogRead(pinO2), 511); //Get the current O2 value.
|
||||
tempReading = fastMap1023toX(analogRead(pinO2), 511); //Get the current O2 value.
|
||||
#endif
|
||||
currentStatus.O2ADC = ADC_FILTER(tempReading, ADCFILTER_O2, currentStatus.O2ADC);
|
||||
currentStatus.O2 = o2CalibrationTable[currentStatus.O2ADC];
|
||||
}
|
||||
|
||||
|
||||
/* Second O2 currently disabled as its not being used
|
||||
currentStatus.O2_2ADC = map(analogRead(pinO2_2), 0, 1023, 0, 511); //Get the current O2 value.
|
||||
currentStatus.O2_2ADC = ADC_FILTER(tempReading, ADCFILTER_O2, currentStatus.O2_2ADC);
|
||||
|
@ -198,7 +204,7 @@ void readO2()
|
|||
|
||||
void readBat()
|
||||
{
|
||||
#if defined(ANALOG_ISR)
|
||||
#if defined(ANALOG_ISR)
|
||||
tempReading = fastMap1023toX(AnChannel[pinBat-A0], 245); //Get the current raw Battery value. Permissible values are from 0v to 24.5v (245)
|
||||
#else
|
||||
tempReading = analogRead(pinBat);
|
||||
|
@ -215,4 +221,3 @@ void flexPulse()
|
|||
{
|
||||
++flexCounter;
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
|
@ -19,128 +19,128 @@ void writeConfig()
|
|||
We only ever write to the EEPROM where the new value is different from the currently stored byte
|
||||
This is due to the limited write life of the EEPROM (Approximately 100,000 writes)
|
||||
*/
|
||||
|
||||
|
||||
int offset;
|
||||
//Create a pointer to the config page
|
||||
byte* pnt_configPage;
|
||||
|
||||
|
||||
if(EEPROM.read(0) != data_structure_version) { EEPROM.write(0,data_structure_version); } //Write the data structure version
|
||||
|
||||
|
||||
|
||||
|
||||
/*---------------------------------------------------
|
||||
| Fuel table (See storage.h for data layout) - Page 1
|
||||
| 16x16 table itself + the 16 values along each of the axis
|
||||
| 16x16 table itself + the 16 values along each of the axis
|
||||
-----------------------------------------------------*/
|
||||
if(EEPROM.read(EEPROM_CONFIG1_XSIZE) != fuelTable.xSize) { EEPROM.write(EEPROM_CONFIG1_XSIZE, fuelTable.xSize); } //Write the VE Tables RPM dimension size
|
||||
if(EEPROM.read(EEPROM_CONFIG1_YSIZE) != fuelTable.ySize) { EEPROM.write(EEPROM_CONFIG1_YSIZE, fuelTable.ySize); } //Write the VE Tables MAP/TPS dimension size
|
||||
for(int x=EEPROM_CONFIG1_MAP; x<EEPROM_CONFIG1_XBINS; x++)
|
||||
{
|
||||
for(int x=EEPROM_CONFIG1_MAP; x<EEPROM_CONFIG1_XBINS; x++)
|
||||
{
|
||||
offset = x - EEPROM_CONFIG1_MAP;
|
||||
if(EEPROM.read(x) != fuelTable.values[15-offset/16][offset%16]) { EEPROM.write(x, fuelTable.values[15-offset/16][offset%16]); } //Write the 16x16 map
|
||||
}
|
||||
|
||||
|
||||
//RPM bins
|
||||
for(int x=EEPROM_CONFIG1_XBINS; x<EEPROM_CONFIG1_YBINS; x++)
|
||||
for(int x=EEPROM_CONFIG1_XBINS; x<EEPROM_CONFIG1_YBINS; x++)
|
||||
{
|
||||
offset = x - EEPROM_CONFIG1_XBINS;
|
||||
if(EEPROM.read(x) != byte(fuelTable.axisX[offset]/TABLE_RPM_MULTIPLIER)) { EEPROM.write(x, byte(fuelTable.axisX[offset]/TABLE_RPM_MULTIPLIER)); } //RPM bins are divided by 100 and converted to a byte
|
||||
}
|
||||
//TPS/MAP bins
|
||||
for(int x=EEPROM_CONFIG1_YBINS; x<EEPROM_CONFIG2_START; x++)
|
||||
for(int x=EEPROM_CONFIG1_YBINS; x<EEPROM_CONFIG2_START; x++)
|
||||
{
|
||||
offset = x - EEPROM_CONFIG1_YBINS;
|
||||
EEPROM.update(x, fuelTable.axisY[offset] / TABLE_LOAD_MULTIPLIER); //Table load is divided by 2 (Allows for MAP up to 511)
|
||||
}
|
||||
//That concludes the writing of the VE table
|
||||
//*********************************************************************************************************************************************************************************
|
||||
|
||||
|
||||
/*---------------------------------------------------
|
||||
| Config page 2 (See storage.h for data layout)
|
||||
| 64 byte long config table
|
||||
-----------------------------------------------------*/
|
||||
pnt_configPage = (byte *)&configPage1; //Create a pointer to Page 2 in memory
|
||||
for(int x=EEPROM_CONFIG2_START; x<EEPROM_CONFIG2_END; x++)
|
||||
{
|
||||
for(int x=EEPROM_CONFIG2_START; x<EEPROM_CONFIG2_END; x++)
|
||||
{
|
||||
if(EEPROM.read(x) != *(pnt_configPage + byte(x - EEPROM_CONFIG2_START))) { EEPROM.write(x, *(pnt_configPage + byte(x - EEPROM_CONFIG2_START))); }
|
||||
}
|
||||
//*********************************************************************************************************************************************************************************
|
||||
|
||||
|
||||
|
||||
/*---------------------------------------------------
|
||||
| Ignition table (See storage.h for data layout) - Page 1
|
||||
| 16x16 table itself + the 16 values along each of the axis
|
||||
| 16x16 table itself + the 16 values along each of the axis
|
||||
-----------------------------------------------------*/
|
||||
//Begin writing the Ignition table, basically the same thing as above
|
||||
if(EEPROM.read(EEPROM_CONFIG3_XSIZE) != ignitionTable.xSize) { EEPROM.write(EEPROM_CONFIG3_XSIZE,ignitionTable.xSize); } //Write the ignition Table RPM dimension size
|
||||
if(EEPROM.read(EEPROM_CONFIG3_YSIZE) != ignitionTable.ySize) { EEPROM.write(EEPROM_CONFIG3_YSIZE,ignitionTable.ySize); } //Write the ignition Table MAP/TPS dimension size
|
||||
|
||||
for(int x=EEPROM_CONFIG3_MAP; x<EEPROM_CONFIG3_XBINS; x++)
|
||||
{
|
||||
|
||||
for(int x=EEPROM_CONFIG3_MAP; x<EEPROM_CONFIG3_XBINS; x++)
|
||||
{
|
||||
offset = x - EEPROM_CONFIG3_MAP;
|
||||
if(EEPROM.read(x) != ignitionTable.values[15-offset/16][offset%16]) { EEPROM.write(x, ignitionTable.values[15-offset/16][offset%16]); } //Write the 16x16 map with translation
|
||||
}
|
||||
//RPM bins
|
||||
for(int x=EEPROM_CONFIG3_XBINS; x<EEPROM_CONFIG3_YBINS; x++)
|
||||
for(int x=EEPROM_CONFIG3_XBINS; x<EEPROM_CONFIG3_YBINS; x++)
|
||||
{
|
||||
offset = x - EEPROM_CONFIG3_XBINS;
|
||||
if(EEPROM.read(x) != byte(ignitionTable.axisX[offset]/TABLE_RPM_MULTIPLIER)) { EEPROM.write(x, byte(ignitionTable.axisX[offset]/TABLE_RPM_MULTIPLIER)); } //RPM bins are divided by 100 and converted to a byte
|
||||
}
|
||||
//TPS/MAP bins
|
||||
for(int x=EEPROM_CONFIG3_YBINS; x<EEPROM_CONFIG4_START; x++)
|
||||
for(int x=EEPROM_CONFIG3_YBINS; x<EEPROM_CONFIG4_START; x++)
|
||||
{
|
||||
offset = x - EEPROM_CONFIG3_YBINS;
|
||||
EEPROM.update(x, ignitionTable.axisY[offset]/TABLE_LOAD_MULTIPLIER); //Table load is divided by 2 (Allows for MAP up to 511)
|
||||
}
|
||||
//That concludes the writing of the IGN table
|
||||
//*********************************************************************************************************************************************************************************
|
||||
|
||||
//*********************************************************************************************************************************************************************************
|
||||
|
||||
/*---------------------------------------------------
|
||||
| Config page 2 (See storage.h for data layout)
|
||||
| 64 byte long config table
|
||||
-----------------------------------------------------*/
|
||||
pnt_configPage = (byte *)&configPage2; //Create a pointer to Page 2 in memory
|
||||
for(int x=EEPROM_CONFIG4_START; x<EEPROM_CONFIG4_END; x++)
|
||||
{
|
||||
for(int x=EEPROM_CONFIG4_START; x<EEPROM_CONFIG4_END; x++)
|
||||
{
|
||||
if(EEPROM.read(x) != *(pnt_configPage + byte(x - EEPROM_CONFIG4_START))) { EEPROM.write(x, *(pnt_configPage + byte(x - EEPROM_CONFIG4_START))); }
|
||||
}
|
||||
//*********************************************************************************************************************************************************************************
|
||||
|
||||
|
||||
|
||||
/*---------------------------------------------------
|
||||
| AFR table (See storage.h for data layout) - Page 5
|
||||
| 16x16 table itself + the 16 values along each of the axis
|
||||
| 16x16 table itself + the 16 values along each of the axis
|
||||
-----------------------------------------------------*/
|
||||
//Begin writing the Ignition table, basically the same thing as above
|
||||
if(EEPROM.read(EEPROM_CONFIG5_XSIZE) != afrTable.xSize) { EEPROM.write(EEPROM_CONFIG5_XSIZE,afrTable.xSize); } //Write the ignition Table RPM dimension size
|
||||
if(EEPROM.read(EEPROM_CONFIG5_YSIZE) != afrTable.ySize) { EEPROM.write(EEPROM_CONFIG5_YSIZE,afrTable.ySize); } //Write the ignition Table MAP/TPS dimension size
|
||||
|
||||
for(int x=EEPROM_CONFIG5_MAP; x<EEPROM_CONFIG5_XBINS; x++)
|
||||
{
|
||||
|
||||
for(int x=EEPROM_CONFIG5_MAP; x<EEPROM_CONFIG5_XBINS; x++)
|
||||
{
|
||||
offset = x - EEPROM_CONFIG5_MAP;
|
||||
if(EEPROM.read(x) != afrTable.values[15-offset/16][offset%16]) { EEPROM.write(x, afrTable.values[15-offset/16][offset%16]); } //Write the 16x16 map
|
||||
}
|
||||
//RPM bins
|
||||
for(int x=EEPROM_CONFIG5_XBINS; x<EEPROM_CONFIG5_YBINS; x++)
|
||||
for(int x=EEPROM_CONFIG5_XBINS; x<EEPROM_CONFIG5_YBINS; x++)
|
||||
{
|
||||
offset = x - EEPROM_CONFIG5_XBINS;
|
||||
if(EEPROM.read(x) != byte(afrTable.axisX[offset]/TABLE_RPM_MULTIPLIER)) { EEPROM.write(x, byte(afrTable.axisX[offset]/TABLE_RPM_MULTIPLIER)); } //RPM bins are divided by 100 and converted to a byte
|
||||
}
|
||||
//TPS/MAP bins
|
||||
for(int x=EEPROM_CONFIG5_YBINS; x<EEPROM_CONFIG6_START; x++)
|
||||
for(int x=EEPROM_CONFIG5_YBINS; x<EEPROM_CONFIG6_START; x++)
|
||||
{
|
||||
offset = x - EEPROM_CONFIG5_YBINS;
|
||||
EEPROM.update(x, afrTable.axisY[offset]/TABLE_LOAD_MULTIPLIER); //Table load is divided by 2 (Allows for MAP up to 511)
|
||||
}
|
||||
//That concludes the writing of the AFR table
|
||||
//*********************************************************************************************************************************************************************************
|
||||
|
||||
|
||||
/*---------------------------------------------------
|
||||
| Config page 3 (See storage.h for data layout)
|
||||
| 64 byte long config table
|
||||
-----------------------------------------------------*/
|
||||
pnt_configPage = (byte *)&configPage3; //Create a pointer to Page 3 in memory
|
||||
for(int x=EEPROM_CONFIG6_START; x<EEPROM_CONFIG6_END; x++)
|
||||
{
|
||||
for(int x=EEPROM_CONFIG6_START; x<EEPROM_CONFIG6_END; x++)
|
||||
{
|
||||
if(EEPROM.read(x) != *(pnt_configPage + byte(x - EEPROM_CONFIG6_START))) { EEPROM.write(x, *(pnt_configPage + byte(x - EEPROM_CONFIG6_START))); }
|
||||
}
|
||||
//*********************************************************************************************************************************************************************************
|
||||
|
@ -148,27 +148,27 @@ void writeConfig()
|
|||
/*---------------------------------------------------
|
||||
| Config page 4 (See storage.h for data layout)
|
||||
| 64 byte long config table
|
||||
-----------------------------------------------------*/
|
||||
-----------------------------------------------------*/
|
||||
pnt_configPage = (byte *)&configPage4; //Create a pointer to Page 4 in memory
|
||||
//The next 128 bytes can simply be pulled straight from the configTable
|
||||
for(int x=EEPROM_CONFIG7_START; x<EEPROM_CONFIG7_END; x++)
|
||||
{
|
||||
for(int x=EEPROM_CONFIG7_START; x<EEPROM_CONFIG7_END; x++)
|
||||
{
|
||||
if(EEPROM.read(x) != *(pnt_configPage + byte(x - EEPROM_CONFIG7_START))) { EEPROM.write(x, *(pnt_configPage + byte(x - EEPROM_CONFIG7_START))); }
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------
|
||||
| Boost and vvt tables (See storage.h for data layout) - Page 8
|
||||
| 8x8 table itself + the 8 values along each of the axis
|
||||
| 8x8 table itself + the 8 values along each of the axis
|
||||
-----------------------------------------------------*/
|
||||
//Begin writing the 2 tables, basically the same thing as above but we're doing these 2 together (2 tables per page instead of 1)
|
||||
if(EEPROM.read(EEPROM_CONFIG8_XSIZE1) != boostTable.xSize) { EEPROM.write(EEPROM_CONFIG8_XSIZE1,boostTable.xSize); } //Write the boost Table RPM dimension size
|
||||
if(EEPROM.read(EEPROM_CONFIG8_YSIZE1) != boostTable.ySize) { EEPROM.write(EEPROM_CONFIG8_YSIZE1,boostTable.ySize); } //Write the boost Table MAP/TPS dimension size
|
||||
if(EEPROM.read(EEPROM_CONFIG8_XSIZE2) != vvtTable.xSize) { EEPROM.write(EEPROM_CONFIG8_XSIZE2,vvtTable.xSize); } //Write the vvt Table RPM dimension size
|
||||
if(EEPROM.read(EEPROM_CONFIG8_YSIZE2) != vvtTable.ySize) { EEPROM.write(EEPROM_CONFIG8_YSIZE2,vvtTable.ySize); } //Write the vvt Table MAP/TPS dimension size
|
||||
|
||||
|
||||
int y = EEPROM_CONFIG8_MAP2; //We do the 2 maps together in the same loop
|
||||
for(int x=EEPROM_CONFIG8_MAP1; x<EEPROM_CONFIG8_XBINS1; x++)
|
||||
{
|
||||
for(int x=EEPROM_CONFIG8_MAP1; x<EEPROM_CONFIG8_XBINS1; x++)
|
||||
{
|
||||
offset = x - EEPROM_CONFIG8_MAP1;
|
||||
if(EEPROM.read(x) != boostTable.values[7-offset/8][offset%8]) { EEPROM.write(x, boostTable.values[7-offset/8][offset%8]); } //Write the 8x8 map
|
||||
offset = y - EEPROM_CONFIG8_MAP2;
|
||||
|
@ -177,7 +177,7 @@ void writeConfig()
|
|||
}
|
||||
//RPM bins
|
||||
y = EEPROM_CONFIG8_XBINS2;
|
||||
for(int x=EEPROM_CONFIG8_XBINS1; x<EEPROM_CONFIG8_YBINS1; x++)
|
||||
for(int x=EEPROM_CONFIG8_XBINS1; x<EEPROM_CONFIG8_YBINS1; x++)
|
||||
{
|
||||
offset = x - EEPROM_CONFIG8_XBINS1;
|
||||
if(EEPROM.read(x) != byte(boostTable.axisX[offset]/TABLE_RPM_MULTIPLIER)) { EEPROM.write(x, byte(boostTable.axisX[offset]/TABLE_RPM_MULTIPLIER)); } //RPM bins are divided by 100 and converted to a byte
|
||||
|
@ -187,18 +187,18 @@ void writeConfig()
|
|||
}
|
||||
//TPS/MAP bins
|
||||
y=EEPROM_CONFIG8_YBINS2;
|
||||
for(int x=EEPROM_CONFIG8_YBINS1; x<EEPROM_CONFIG8_XSIZE2; x++)
|
||||
for(int x=EEPROM_CONFIG8_YBINS1; x<EEPROM_CONFIG8_XSIZE2; x++)
|
||||
{
|
||||
offset = x - EEPROM_CONFIG8_YBINS1;
|
||||
EEPROM.update(x, boostTable.axisY[offset]/TABLE_LOAD_MULTIPLIER); //Table load is divided by 2 (Allows for MAP up to 511)
|
||||
EEPROM.update(x, boostTable.axisY[offset]); //TABLE_LOAD_MULTIPLIER is NOT used for boost as it is TPS based (0-100)
|
||||
offset = y - EEPROM_CONFIG8_YBINS2;
|
||||
EEPROM.update(y, vvtTable.axisY[offset]/TABLE_LOAD_MULTIPLIER); //Table load is divided by 2 (Allows for MAP up to 511)
|
||||
EEPROM.update(y, vvtTable.axisY[offset]); //TABLE_LOAD_MULTIPLIER is NOT used for VVT as it is TPS based (0-100)
|
||||
y++;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------
|
||||
| Fuel trim tables (See storage.h for data layout) - Page 9
|
||||
| 6x6 tables itself + the 6 values along each of the axis
|
||||
| 6x6 tables itself + the 6 values along each of the axis
|
||||
-----------------------------------------------------*/
|
||||
//Begin writing the 2 tables, basically the same thing as above but we're doing these 2 together (2 tables per page instead of 1)
|
||||
EEPROM.update(EEPROM_CONFIG9_XSIZE1,trim1Table.xSize); //Write the boost Table RPM dimension size
|
||||
|
@ -209,12 +209,12 @@ void writeConfig()
|
|||
EEPROM.update(EEPROM_CONFIG9_YSIZE3,trim3Table.ySize); //Write the boost Table MAP/TPS dimension size
|
||||
EEPROM.update(EEPROM_CONFIG9_XSIZE4,trim4Table.xSize); //Write the boost Table RPM dimension size
|
||||
EEPROM.update(EEPROM_CONFIG9_YSIZE4,trim4Table.ySize); //Write the boost Table MAP/TPS dimension size
|
||||
|
||||
|
||||
y = EEPROM_CONFIG9_MAP2; //We do the 4 maps together in the same loop
|
||||
int z = EEPROM_CONFIG9_MAP3; //We do the 4 maps together in the same loop
|
||||
int i = EEPROM_CONFIG9_MAP4; //We do the 4 maps together in the same loop
|
||||
for(int x=EEPROM_CONFIG9_MAP1; x<EEPROM_CONFIG9_XBINS1; x++)
|
||||
{
|
||||
for(int x=EEPROM_CONFIG9_MAP1; x<EEPROM_CONFIG9_XBINS1; x++)
|
||||
{
|
||||
offset = x - EEPROM_CONFIG9_MAP1;
|
||||
EEPROM.update(x, trim1Table.values[5-offset/6][offset%6]); //Write the 6x6 map
|
||||
offset = y - EEPROM_CONFIG9_MAP2;
|
||||
|
@ -231,7 +231,7 @@ void writeConfig()
|
|||
y = EEPROM_CONFIG9_XBINS2;
|
||||
z = EEPROM_CONFIG9_XBINS3;
|
||||
i = EEPROM_CONFIG9_XBINS4;
|
||||
for(int x=EEPROM_CONFIG9_XBINS1; x<EEPROM_CONFIG9_YBINS1; x++)
|
||||
for(int x=EEPROM_CONFIG9_XBINS1; x<EEPROM_CONFIG9_YBINS1; x++)
|
||||
{
|
||||
offset = x - EEPROM_CONFIG9_XBINS1;
|
||||
EEPROM.update(x, byte(trim1Table.axisX[offset]/TABLE_RPM_MULTIPLIER)); //RPM bins are divided by 100 and converted to a byte
|
||||
|
@ -249,7 +249,7 @@ void writeConfig()
|
|||
y=EEPROM_CONFIG9_YBINS2;
|
||||
z=EEPROM_CONFIG9_YBINS3;
|
||||
i=EEPROM_CONFIG9_YBINS4;
|
||||
for(int x=EEPROM_CONFIG9_YBINS1; x<EEPROM_CONFIG9_XSIZE2; x++)
|
||||
for(int x=EEPROM_CONFIG9_YBINS1; x<EEPROM_CONFIG9_XSIZE2; x++)
|
||||
{
|
||||
offset = x - EEPROM_CONFIG9_YBINS1;
|
||||
EEPROM.update(x, trim1Table.axisY[offset]/TABLE_LOAD_MULTIPLIER); //Table load is divided by 2 (Allows for MAP up to 511)
|
||||
|
@ -264,14 +264,14 @@ void writeConfig()
|
|||
i++;
|
||||
}
|
||||
//*********************************************************************************************************************************************************************************
|
||||
|
||||
|
||||
/*---------------------------------------------------
|
||||
| Config page 10 (See storage.h for data layout)
|
||||
| 128 byte long config table
|
||||
-----------------------------------------------------*/
|
||||
pnt_configPage = (byte *)&configPage10; //Create a pointer to Page 10 in memory
|
||||
for(int x=EEPROM_CONFIG10_START; x<EEPROM_CONFIG10_END; x++)
|
||||
{
|
||||
for(int x=EEPROM_CONFIG10_START; x<EEPROM_CONFIG10_END; x++)
|
||||
{
|
||||
if(EEPROM.read(x) != *(pnt_configPage + byte(x - EEPROM_CONFIG10_START))) { EEPROM.write(x, *(pnt_configPage + byte(x - EEPROM_CONFIG10_START))); }
|
||||
}
|
||||
//*********************************************************************************************************************************************************************************
|
||||
|
@ -283,117 +283,117 @@ void loadConfig()
|
|||
int offset;
|
||||
//Create a pointer to the config page
|
||||
byte* pnt_configPage;
|
||||
|
||||
|
||||
|
||||
|
||||
//Fuel table (See storage.h for data layout)
|
||||
//fuelTable.xSize = EEPROM.read(EEPROM_CONFIG1_XSIZE); //Read the VE Tables RPM dimension size
|
||||
//fuelTable.ySize = EEPROM.read(EEPROM_CONFIG1_YSIZE); //Read the VE Tables MAP/TPS dimension size
|
||||
for(int x=EEPROM_CONFIG1_MAP; x<EEPROM_CONFIG1_XBINS; x++)
|
||||
{
|
||||
for(int x=EEPROM_CONFIG1_MAP; x<EEPROM_CONFIG1_XBINS; x++)
|
||||
{
|
||||
offset = x - EEPROM_CONFIG1_MAP;
|
||||
fuelTable.values[15-offset/16][offset%16] = EEPROM.read(x); //Read the 8x8 map
|
||||
}
|
||||
//RPM bins
|
||||
for(int x=EEPROM_CONFIG1_XBINS; x<EEPROM_CONFIG1_YBINS; x++)
|
||||
for(int x=EEPROM_CONFIG1_XBINS; x<EEPROM_CONFIG1_YBINS; x++)
|
||||
{
|
||||
offset = x - EEPROM_CONFIG1_XBINS;
|
||||
fuelTable.axisX[offset] = (EEPROM.read(x) * TABLE_RPM_MULTIPLIER); //RPM bins are divided by 100 when stored. Multiply them back now
|
||||
}
|
||||
//TPS/MAP bins
|
||||
for(int x=EEPROM_CONFIG1_YBINS; x<EEPROM_CONFIG2_START; x++)
|
||||
for(int x=EEPROM_CONFIG1_YBINS; x<EEPROM_CONFIG2_START; x++)
|
||||
{
|
||||
offset = x - EEPROM_CONFIG1_YBINS;
|
||||
fuelTable.axisY[offset] = EEPROM.read(x) * TABLE_LOAD_MULTIPLIER;
|
||||
}
|
||||
|
||||
|
||||
pnt_configPage = (byte *)&configPage1; //Create a pointer to Page 1 in memory
|
||||
for(int x=EEPROM_CONFIG2_START; x<EEPROM_CONFIG2_END; x++)
|
||||
{
|
||||
for(int x=EEPROM_CONFIG2_START; x<EEPROM_CONFIG2_END; x++)
|
||||
{
|
||||
*(pnt_configPage + byte(x - EEPROM_CONFIG2_START)) = EEPROM.read(x);
|
||||
}
|
||||
//That concludes the reading of the VE table
|
||||
|
||||
|
||||
//*********************************************************************************************************************************************************************************
|
||||
//IGNITION CONFIG PAGE (2)
|
||||
|
||||
//Begin writing the Ignition table, basically the same thing as above
|
||||
//ignitionTable.xSize = EEPROM.read(EEPROM_CONFIG2_XSIZE); //Read the ignition Table RPM dimension size (Currently not supproted)
|
||||
//ignitionTable.ySize = EEPROM.read(EEPROM_CONFIG2_YSIZE); //Read the ignition Table MAP/TPS dimension size (Currently not supproted)
|
||||
|
||||
for(int x=EEPROM_CONFIG3_MAP; x<EEPROM_CONFIG3_XBINS; x++)
|
||||
{
|
||||
|
||||
for(int x=EEPROM_CONFIG3_MAP; x<EEPROM_CONFIG3_XBINS; x++)
|
||||
{
|
||||
offset = x - EEPROM_CONFIG3_MAP;
|
||||
ignitionTable.values[15-offset/16][offset%16] = EEPROM.read(x); //Read the 8x8 map
|
||||
}
|
||||
//RPM bins
|
||||
for(int x=EEPROM_CONFIG3_XBINS; x<EEPROM_CONFIG3_YBINS; x++)
|
||||
for(int x=EEPROM_CONFIG3_XBINS; x<EEPROM_CONFIG3_YBINS; x++)
|
||||
{
|
||||
offset = x - EEPROM_CONFIG3_XBINS;
|
||||
ignitionTable.axisX[offset] = (EEPROM.read(x) * TABLE_RPM_MULTIPLIER); //RPM bins are divided by 100 when stored. Multiply them back now
|
||||
}
|
||||
//TPS/MAP bins
|
||||
for(int x=EEPROM_CONFIG3_YBINS; x<EEPROM_CONFIG4_START; x++)
|
||||
for(int x=EEPROM_CONFIG3_YBINS; x<EEPROM_CONFIG4_START; x++)
|
||||
{
|
||||
offset = x - EEPROM_CONFIG3_YBINS;
|
||||
ignitionTable.axisY[offset] = EEPROM.read(x) * TABLE_LOAD_MULTIPLIER; //Table load is divided by 2 (Allows for MAP up to 511)
|
||||
}
|
||||
|
||||
|
||||
pnt_configPage = (byte *)&configPage2; //Create a pointer to Page 2 in memory
|
||||
for(int x=EEPROM_CONFIG4_START; x<EEPROM_CONFIG4_END; x++)
|
||||
{
|
||||
for(int x=EEPROM_CONFIG4_START; x<EEPROM_CONFIG4_END; x++)
|
||||
{
|
||||
*(pnt_configPage + byte(x - EEPROM_CONFIG4_START)) = EEPROM.read(x);
|
||||
}
|
||||
|
||||
|
||||
//*********************************************************************************************************************************************************************************
|
||||
//AFR TARGET CONFIG PAGE (3)
|
||||
|
||||
|
||||
//Begin writing the Ignition table, basically the same thing as above
|
||||
//ignitionTable.xSize = EEPROM.read(EEPROM_CONFIG2_XSIZE); //Read the ignition Table RPM dimension size (Currently not supproted)
|
||||
//ignitionTable.ySize = EEPROM.read(EEPROM_CONFIG2_YSIZE); //Read the ignition Table MAP/TPS dimension size (Currently not supproted)
|
||||
|
||||
for(int x=EEPROM_CONFIG5_MAP; x<EEPROM_CONFIG5_XBINS; x++)
|
||||
{
|
||||
|
||||
for(int x=EEPROM_CONFIG5_MAP; x<EEPROM_CONFIG5_XBINS; x++)
|
||||
{
|
||||
offset = x - EEPROM_CONFIG5_MAP;
|
||||
afrTable.values[15-offset/16][offset%16] = EEPROM.read(x); //Read the 16x16 map
|
||||
}
|
||||
//RPM bins
|
||||
for(int x=EEPROM_CONFIG5_XBINS; x<EEPROM_CONFIG5_YBINS; x++)
|
||||
for(int x=EEPROM_CONFIG5_XBINS; x<EEPROM_CONFIG5_YBINS; x++)
|
||||
{
|
||||
offset = x - EEPROM_CONFIG5_XBINS;
|
||||
afrTable.axisX[offset] = (EEPROM.read(x) * TABLE_RPM_MULTIPLIER); //RPM bins are divided by 100 when stored. Multiply them back now
|
||||
}
|
||||
//TPS/MAP bins
|
||||
for(int x=EEPROM_CONFIG5_YBINS; x<EEPROM_CONFIG6_START; x++)
|
||||
for(int x=EEPROM_CONFIG5_YBINS; x<EEPROM_CONFIG6_START; x++)
|
||||
{
|
||||
offset = x - EEPROM_CONFIG5_YBINS;
|
||||
afrTable.axisY[offset] = EEPROM.read(x) * TABLE_LOAD_MULTIPLIER; //Table load is divided by 2 (Allows for MAP up to 511)
|
||||
}
|
||||
|
||||
|
||||
pnt_configPage = (byte *)&configPage3; //Create a pointer to Page 2 in memory
|
||||
for(int x=EEPROM_CONFIG6_START; x<EEPROM_CONFIG6_END; x++)
|
||||
{
|
||||
for(int x=EEPROM_CONFIG6_START; x<EEPROM_CONFIG6_END; x++)
|
||||
{
|
||||
*(pnt_configPage + byte(x - EEPROM_CONFIG6_START)) = EEPROM.read(x);
|
||||
}
|
||||
|
||||
|
||||
//*********************************************************************************************************************************************************************************
|
||||
|
||||
|
||||
//CONFIG PAGE (4) //############
|
||||
pnt_configPage = (byte *)&configPage4; //Create a pointer to Page 3 in memory
|
||||
//Begin writing the Ignition table, basically the same thing as above
|
||||
//ignitionTable.xSize = EEPROM.read(EEPROM_CONFIG2_XSIZE); //Read the ignition Table RPM dimension size (Currently not supproted)
|
||||
//ignitionTable.ySize = EEPROM.read(EEPROM_CONFIG2_YSIZE); //Read the ignition Table MAP/TPS dimension size (Currently not supproted)
|
||||
|
||||
|
||||
//The next 64 bytes can simply be pulled straight from the configTable
|
||||
for(int x=EEPROM_CONFIG7_START; x<EEPROM_CONFIG7_END; x++)
|
||||
{
|
||||
for(int x=EEPROM_CONFIG7_START; x<EEPROM_CONFIG7_END; x++)
|
||||
{
|
||||
*(pnt_configPage + byte(x - EEPROM_CONFIG7_START)) = EEPROM.read(x);
|
||||
}
|
||||
|
||||
|
||||
//*********************************************************************************************************************************************************************************
|
||||
// Boost and vvt tables load
|
||||
int y = EEPROM_CONFIG8_MAP2;
|
||||
for(int x=EEPROM_CONFIG8_MAP1; x<EEPROM_CONFIG8_XBINS1; x++)
|
||||
{
|
||||
for(int x=EEPROM_CONFIG8_MAP1; x<EEPROM_CONFIG8_XBINS1; x++)
|
||||
{
|
||||
offset = x - EEPROM_CONFIG8_MAP1;
|
||||
boostTable.values[7-offset/8][offset%8] = EEPROM.read(x); //Read the 8x8 map
|
||||
offset = y - EEPROM_CONFIG8_MAP2;
|
||||
|
@ -403,7 +403,7 @@ void loadConfig()
|
|||
|
||||
//RPM bins
|
||||
y = EEPROM_CONFIG8_XBINS2;
|
||||
for(int x=EEPROM_CONFIG8_XBINS1; x<EEPROM_CONFIG8_YBINS1; x++)
|
||||
for(int x=EEPROM_CONFIG8_XBINS1; x<EEPROM_CONFIG8_YBINS1; x++)
|
||||
{
|
||||
offset = x - EEPROM_CONFIG8_XBINS1;
|
||||
boostTable.axisX[offset] = (EEPROM.read(x) * TABLE_RPM_MULTIPLIER); //RPM bins are divided by 100 when stored. Multiply them back now
|
||||
|
@ -411,15 +411,15 @@ void loadConfig()
|
|||
vvtTable.axisX[offset] = (EEPROM.read(y) * TABLE_RPM_MULTIPLIER); //RPM bins are divided by 100 when stored. Multiply them back now
|
||||
y++;
|
||||
}
|
||||
|
||||
|
||||
//TPS/MAP bins
|
||||
y = EEPROM_CONFIG8_YBINS2;
|
||||
for(int x=EEPROM_CONFIG8_YBINS1; x<EEPROM_CONFIG8_XSIZE2; x++)
|
||||
for(int x=EEPROM_CONFIG8_YBINS1; x<EEPROM_CONFIG8_XSIZE2; x++)
|
||||
{
|
||||
offset = x - EEPROM_CONFIG8_YBINS1;
|
||||
boostTable.axisY[offset] = EEPROM.read(x) * TABLE_LOAD_MULTIPLIER; //Table load is divided by 2 (Allows for MAP up to 511)
|
||||
boostTable.axisY[offset] = EEPROM.read(x); //TABLE_LOAD_MULTIPLIER is NOT used for boost as it is TPS based (0-100)
|
||||
offset = y - EEPROM_CONFIG8_YBINS2;
|
||||
vvtTable.axisY[offset] = EEPROM.read(y) * TABLE_LOAD_MULTIPLIER; //Table load is divided by 2 (Allows for MAP up to 511)
|
||||
vvtTable.axisY[offset] = EEPROM.read(y); //TABLE_LOAD_MULTIPLIER is NOT used for VVT as it is TPS based (0-100)
|
||||
y++;
|
||||
}
|
||||
|
||||
|
@ -428,8 +428,8 @@ void loadConfig()
|
|||
y = EEPROM_CONFIG9_MAP2;
|
||||
int z = EEPROM_CONFIG9_MAP3;
|
||||
int i = EEPROM_CONFIG9_MAP4;
|
||||
for(int x=EEPROM_CONFIG9_MAP1; x<EEPROM_CONFIG9_XBINS1; x++)
|
||||
{
|
||||
for(int x=EEPROM_CONFIG9_MAP1; x<EEPROM_CONFIG9_XBINS1; x++)
|
||||
{
|
||||
offset = x - EEPROM_CONFIG9_MAP1;
|
||||
trim1Table.values[5-offset/6][offset%6] = EEPROM.read(x); //Read the 6x6 map
|
||||
offset = y - EEPROM_CONFIG9_MAP2;
|
||||
|
@ -447,7 +447,7 @@ void loadConfig()
|
|||
y = EEPROM_CONFIG9_XBINS2;
|
||||
z = EEPROM_CONFIG9_XBINS3;
|
||||
i = EEPROM_CONFIG9_XBINS4;
|
||||
for(int x=EEPROM_CONFIG9_XBINS1; x<EEPROM_CONFIG9_YBINS1; x++)
|
||||
for(int x=EEPROM_CONFIG9_XBINS1; x<EEPROM_CONFIG9_YBINS1; x++)
|
||||
{
|
||||
offset = x - EEPROM_CONFIG9_XBINS1;
|
||||
trim1Table.axisX[offset] = (EEPROM.read(x) * TABLE_RPM_MULTIPLIER); //RPM bins are divided by 100 when stored. Multiply them back now
|
||||
|
@ -461,12 +461,12 @@ void loadConfig()
|
|||
z++;
|
||||
i++;
|
||||
}
|
||||
|
||||
|
||||
//TPS/MAP bins
|
||||
y = EEPROM_CONFIG9_YBINS2;
|
||||
z = EEPROM_CONFIG9_YBINS3;
|
||||
i = EEPROM_CONFIG9_YBINS4;
|
||||
for(int x=EEPROM_CONFIG9_YBINS1; x<EEPROM_CONFIG9_XSIZE2; x++)
|
||||
for(int x=EEPROM_CONFIG9_YBINS1; x<EEPROM_CONFIG9_XSIZE2; x++)
|
||||
{
|
||||
offset = x - EEPROM_CONFIG9_YBINS1;
|
||||
trim1Table.axisY[offset] = EEPROM.read(x) * TABLE_LOAD_MULTIPLIER; //Table load is divided by 2 (Allows for MAP up to 511)
|
||||
|
@ -483,13 +483,13 @@ void loadConfig()
|
|||
//*********************************************************************************************************************************************************************************
|
||||
//canbus control page load
|
||||
pnt_configPage = (byte *)&configPage10; //Create a pointer to Page 10 in memory
|
||||
for(int x=EEPROM_CONFIG10_START; x<EEPROM_CONFIG10_END; x++)
|
||||
{
|
||||
for(int x=EEPROM_CONFIG10_START; x<EEPROM_CONFIG10_END; x++)
|
||||
{
|
||||
*(pnt_configPage + byte(x - EEPROM_CONFIG10_START)) = EEPROM.read(x);
|
||||
}
|
||||
|
||||
|
||||
//*********************************************************************************************************************************************************************************
|
||||
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -498,38 +498,38 @@ This is separate from the config load as the calibrations do not exist as pages
|
|||
*/
|
||||
void loadCalibration()
|
||||
{
|
||||
|
||||
|
||||
for(int x=0; x<CALIBRATION_TABLE_SIZE; x++) //Each calibration table is 512 bytes long
|
||||
{
|
||||
int y = EEPROM_CALIBRATION_CLT + x;
|
||||
cltCalibrationTable[x] = EEPROM.read(y);
|
||||
|
||||
|
||||
y = EEPROM_CALIBRATION_IAT + x;
|
||||
iatCalibrationTable[x] = EEPROM.read(y);
|
||||
|
||||
|
||||
y = EEPROM_CALIBRATION_O2 + x;
|
||||
o2CalibrationTable[x] = EEPROM.read(y);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
This takes the values in the 3 calibration tables (Coolant, Inlet temp and O2)
|
||||
This takes the values in the 3 calibration tables (Coolant, Inlet temp and O2)
|
||||
and saves them to the EEPROM.
|
||||
*/
|
||||
void writeCalibration()
|
||||
{
|
||||
|
||||
|
||||
for(int x=0; x<CALIBRATION_TABLE_SIZE; x++) //Each calibration table is 512 bytes long
|
||||
{
|
||||
int y = EEPROM_CALIBRATION_CLT + x;
|
||||
if(EEPROM.read(y) != cltCalibrationTable[x]) { EEPROM.write(y, cltCalibrationTable[x]); }
|
||||
|
||||
|
||||
y = EEPROM_CALIBRATION_IAT + x;
|
||||
if(EEPROM.read(y) != iatCalibrationTable[x]) { EEPROM.write(y, iatCalibrationTable[x]); }
|
||||
|
||||
|
||||
y = EEPROM_CALIBRATION_O2 + x;
|
||||
if(EEPROM.read(y) != o2CalibrationTable[x]) { EEPROM.write(y, o2CalibrationTable[x]); }
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -371,6 +371,8 @@ void setPinMapping(byte boardID)
|
|||
pinMode(pinFan, OUTPUT);
|
||||
pinMode(pinStepperDir, OUTPUT);
|
||||
pinMode(pinStepperStep, OUTPUT);
|
||||
pinMode(pinBoost, OUTPUT);
|
||||
pinMode(pinVVT_1, OUTPUT);
|
||||
|
||||
inj1_pin_port = portOutputRegister(digitalPinToPort(pinInjector1));
|
||||
inj1_pin_mask = digitalPinToBitMask(pinInjector1);
|
|
@ -1,520 +0,0 @@
|
|||
/*
|
||||
This is the core graphics library for all our displays, providing a common
|
||||
set of graphics primitives (points, lines, circles, etc.). It needs to be
|
||||
paired with a hardware-specific library for each display device we carry
|
||||
(to handle the lower-level functions).
|
||||
|
||||
Adafruit invests time and resources providing this open source code, please
|
||||
support Adafruit & open-source hardware by purchasing products from Adafruit!
|
||||
|
||||
Copyright (c) 2013 Adafruit Industries. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
- Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
- Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "Adafruit_GFX.h"
|
||||
#include "glcdfont.c"
|
||||
#ifdef __AVR__
|
||||
#include <avr/pgmspace.h>
|
||||
#else
|
||||
#define pgm_read_byte(addr) (*(const unsigned char *)(addr))
|
||||
#endif
|
||||
|
||||
Adafruit_GFX::Adafruit_GFX(int16_t w, int16_t h):
|
||||
WIDTH(w), HEIGHT(h)
|
||||
{
|
||||
_width = WIDTH;
|
||||
_height = HEIGHT;
|
||||
rotation = 0;
|
||||
cursor_y = cursor_x = 0;
|
||||
textsize = 1;
|
||||
textcolor = textbgcolor = 0xFFFF;
|
||||
wrap = true;
|
||||
}
|
||||
|
||||
// Draw a circle outline
|
||||
void Adafruit_GFX::drawCircle(int16_t x0, int16_t y0, int16_t r,
|
||||
uint16_t color) {
|
||||
int16_t f = 1 - r;
|
||||
int16_t ddF_x = 1;
|
||||
int16_t ddF_y = -2 * r;
|
||||
int16_t x = 0;
|
||||
int16_t y = r;
|
||||
|
||||
drawPixel(x0 , y0+r, color);
|
||||
drawPixel(x0 , y0-r, color);
|
||||
drawPixel(x0+r, y0 , color);
|
||||
drawPixel(x0-r, y0 , color);
|
||||
|
||||
while (x<y) {
|
||||
if (f >= 0) {
|
||||
y--;
|
||||
ddF_y += 2;
|
||||
f += ddF_y;
|
||||
}
|
||||
x++;
|
||||
ddF_x += 2;
|
||||
f += ddF_x;
|
||||
|
||||
drawPixel(x0 + x, y0 + y, color);
|
||||
drawPixel(x0 - x, y0 + y, color);
|
||||
drawPixel(x0 + x, y0 - y, color);
|
||||
drawPixel(x0 - x, y0 - y, color);
|
||||
drawPixel(x0 + y, y0 + x, color);
|
||||
drawPixel(x0 - y, y0 + x, color);
|
||||
drawPixel(x0 + y, y0 - x, color);
|
||||
drawPixel(x0 - y, y0 - x, color);
|
||||
}
|
||||
}
|
||||
|
||||
void Adafruit_GFX::drawCircleHelper( int16_t x0, int16_t y0,
|
||||
int16_t r, uint8_t cornername, uint16_t color) {
|
||||
int16_t f = 1 - r;
|
||||
int16_t ddF_x = 1;
|
||||
int16_t ddF_y = -2 * r;
|
||||
int16_t x = 0;
|
||||
int16_t y = r;
|
||||
|
||||
while (x<y) {
|
||||
if (f >= 0) {
|
||||
y--;
|
||||
ddF_y += 2;
|
||||
f += ddF_y;
|
||||
}
|
||||
x++;
|
||||
ddF_x += 2;
|
||||
f += ddF_x;
|
||||
if (cornername & 0x4) {
|
||||
drawPixel(x0 + x, y0 + y, color);
|
||||
drawPixel(x0 + y, y0 + x, color);
|
||||
}
|
||||
if (cornername & 0x2) {
|
||||
drawPixel(x0 + x, y0 - y, color);
|
||||
drawPixel(x0 + y, y0 - x, color);
|
||||
}
|
||||
if (cornername & 0x8) {
|
||||
drawPixel(x0 - y, y0 + x, color);
|
||||
drawPixel(x0 - x, y0 + y, color);
|
||||
}
|
||||
if (cornername & 0x1) {
|
||||
drawPixel(x0 - y, y0 - x, color);
|
||||
drawPixel(x0 - x, y0 - y, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Adafruit_GFX::fillCircle(int16_t x0, int16_t y0, int16_t r,
|
||||
uint16_t color) {
|
||||
drawFastVLine(x0, y0-r, 2*r+1, color);
|
||||
fillCircleHelper(x0, y0, r, 3, 0, color);
|
||||
}
|
||||
|
||||
// Used to do circles and roundrects
|
||||
void Adafruit_GFX::fillCircleHelper(int16_t x0, int16_t y0, int16_t r,
|
||||
uint8_t cornername, int16_t delta, uint16_t color) {
|
||||
|
||||
int16_t f = 1 - r;
|
||||
int16_t ddF_x = 1;
|
||||
int16_t ddF_y = -2 * r;
|
||||
int16_t x = 0;
|
||||
int16_t y = r;
|
||||
|
||||
while (x<y) {
|
||||
if (f >= 0) {
|
||||
y--;
|
||||
ddF_y += 2;
|
||||
f += ddF_y;
|
||||
}
|
||||
x++;
|
||||
ddF_x += 2;
|
||||
f += ddF_x;
|
||||
|
||||
if (cornername & 0x1) {
|
||||
drawFastVLine(x0+x, y0-y, 2*y+1+delta, color);
|
||||
drawFastVLine(x0+y, y0-x, 2*x+1+delta, color);
|
||||
}
|
||||
if (cornername & 0x2) {
|
||||
drawFastVLine(x0-x, y0-y, 2*y+1+delta, color);
|
||||
drawFastVLine(x0-y, y0-x, 2*x+1+delta, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Bresenham's algorithm - thx wikpedia
|
||||
void Adafruit_GFX::drawLine(int16_t x0, int16_t y0,
|
||||
int16_t x1, int16_t y1,
|
||||
uint16_t color) {
|
||||
int16_t steep = abs(y1 - y0) > abs(x1 - x0);
|
||||
if (steep) {
|
||||
swap(x0, y0);
|
||||
swap(x1, y1);
|
||||
}
|
||||
|
||||
if (x0 > x1) {
|
||||
swap(x0, x1);
|
||||
swap(y0, y1);
|
||||
}
|
||||
|
||||
int16_t dx, dy;
|
||||
dx = x1 - x0;
|
||||
dy = abs(y1 - y0);
|
||||
|
||||
int16_t err = dx / 2;
|
||||
int16_t ystep;
|
||||
|
||||
if (y0 < y1) {
|
||||
ystep = 1;
|
||||
} else {
|
||||
ystep = -1;
|
||||
}
|
||||
|
||||
for (; x0<=x1; x0++) {
|
||||
if (steep) {
|
||||
drawPixel(y0, x0, color);
|
||||
} else {
|
||||
drawPixel(x0, y0, color);
|
||||
}
|
||||
err -= dy;
|
||||
if (err < 0) {
|
||||
y0 += ystep;
|
||||
err += dx;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Draw a rectangle
|
||||
void Adafruit_GFX::drawRect(int16_t x, int16_t y,
|
||||
int16_t w, int16_t h,
|
||||
uint16_t color) {
|
||||
drawFastHLine(x, y, w, color);
|
||||
drawFastHLine(x, y+h-1, w, color);
|
||||
drawFastVLine(x, y, h, color);
|
||||
drawFastVLine(x+w-1, y, h, color);
|
||||
}
|
||||
|
||||
void Adafruit_GFX::drawFastVLine(int16_t x, int16_t y,
|
||||
int16_t h, uint16_t color) {
|
||||
// Update in subclasses if desired!
|
||||
drawLine(x, y, x, y+h-1, color);
|
||||
}
|
||||
|
||||
void Adafruit_GFX::drawFastHLine(int16_t x, int16_t y,
|
||||
int16_t w, uint16_t color) {
|
||||
// Update in subclasses if desired!
|
||||
drawLine(x, y, x+w-1, y, color);
|
||||
}
|
||||
|
||||
void Adafruit_GFX::fillRect(int16_t x, int16_t y, int16_t w, int16_t h,
|
||||
uint16_t color) {
|
||||
// Update in subclasses if desired!
|
||||
for (int16_t i=x; i<x+w; i++) {
|
||||
drawFastVLine(i, y, h, color);
|
||||
}
|
||||
}
|
||||
|
||||
void Adafruit_GFX::fillScreen(uint16_t color) {
|
||||
fillRect(0, 0, _width, _height, color);
|
||||
}
|
||||
|
||||
// Draw a rounded rectangle
|
||||
void Adafruit_GFX::drawRoundRect(int16_t x, int16_t y, int16_t w,
|
||||
int16_t h, int16_t r, uint16_t color) {
|
||||
// smarter version
|
||||
drawFastHLine(x+r , y , w-2*r, color); // Top
|
||||
drawFastHLine(x+r , y+h-1, w-2*r, color); // Bottom
|
||||
drawFastVLine(x , y+r , h-2*r, color); // Left
|
||||
drawFastVLine(x+w-1, y+r , h-2*r, color); // Right
|
||||
// draw four corners
|
||||
drawCircleHelper(x+r , y+r , r, 1, color);
|
||||
drawCircleHelper(x+w-r-1, y+r , r, 2, color);
|
||||
drawCircleHelper(x+w-r-1, y+h-r-1, r, 4, color);
|
||||
drawCircleHelper(x+r , y+h-r-1, r, 8, color);
|
||||
}
|
||||
|
||||
// Fill a rounded rectangle
|
||||
void Adafruit_GFX::fillRoundRect(int16_t x, int16_t y, int16_t w,
|
||||
int16_t h, int16_t r, uint16_t color) {
|
||||
// smarter version
|
||||
fillRect(x+r, y, w-2*r, h, color);
|
||||
|
||||
// draw four corners
|
||||
fillCircleHelper(x+w-r-1, y+r, r, 1, h-2*r-1, color);
|
||||
fillCircleHelper(x+r , y+r, r, 2, h-2*r-1, color);
|
||||
}
|
||||
|
||||
// Draw a triangle
|
||||
void Adafruit_GFX::drawTriangle(int16_t x0, int16_t y0,
|
||||
int16_t x1, int16_t y1,
|
||||
int16_t x2, int16_t y2, uint16_t color) {
|
||||
drawLine(x0, y0, x1, y1, color);
|
||||
drawLine(x1, y1, x2, y2, color);
|
||||
drawLine(x2, y2, x0, y0, color);
|
||||
}
|
||||
|
||||
// Fill a triangle
|
||||
void Adafruit_GFX::fillTriangle ( int16_t x0, int16_t y0,
|
||||
int16_t x1, int16_t y1,
|
||||
int16_t x2, int16_t y2, uint16_t color) {
|
||||
|
||||
int16_t a, b, y, last;
|
||||
|
||||
// Sort coordinates by Y order (y2 >= y1 >= y0)
|
||||
if (y0 > y1) {
|
||||
swap(y0, y1); swap(x0, x1);
|
||||
}
|
||||
if (y1 > y2) {
|
||||
swap(y2, y1); swap(x2, x1);
|
||||
}
|
||||
if (y0 > y1) {
|
||||
swap(y0, y1); swap(x0, x1);
|
||||
}
|
||||
|
||||
if(y0 == y2) { // Handle awkward all-on-same-line case as its own thing
|
||||
a = b = x0;
|
||||
if(x1 < a) a = x1;
|
||||
else if(x1 > b) b = x1;
|
||||
if(x2 < a) a = x2;
|
||||
else if(x2 > b) b = x2;
|
||||
drawFastHLine(a, y0, b-a+1, color);
|
||||
return;
|
||||
}
|
||||
|
||||
int16_t
|
||||
dx01 = x1 - x0,
|
||||
dy01 = y1 - y0,
|
||||
dx02 = x2 - x0,
|
||||
dy02 = y2 - y0,
|
||||
dx12 = x2 - x1,
|
||||
dy12 = y2 - y1;
|
||||
int32_t
|
||||
sa = 0,
|
||||
sb = 0;
|
||||
|
||||
// For upper part of triangle, find scanline crossings for segments
|
||||
// 0-1 and 0-2. If y1=y2 (flat-bottomed triangle), the scanline y1
|
||||
// is included here (and second loop will be skipped, avoiding a /0
|
||||
// error there), otherwise scanline y1 is skipped here and handled
|
||||
// in the second loop...which also avoids a /0 error here if y0=y1
|
||||
// (flat-topped triangle).
|
||||
if(y1 == y2) last = y1; // Include y1 scanline
|
||||
else last = y1-1; // Skip it
|
||||
|
||||
for(y=y0; y<=last; y++) {
|
||||
a = x0 + sa / dy01;
|
||||
b = x0 + sb / dy02;
|
||||
sa += dx01;
|
||||
sb += dx02;
|
||||
/* longhand:
|
||||
a = x0 + (x1 - x0) * (y - y0) / (y1 - y0);
|
||||
b = x0 + (x2 - x0) * (y - y0) / (y2 - y0);
|
||||
*/
|
||||
if(a > b) swap(a,b);
|
||||
drawFastHLine(a, y, b-a+1, color);
|
||||
}
|
||||
|
||||
// For lower part of triangle, find scanline crossings for segments
|
||||
// 0-2 and 1-2. This loop is skipped if y1=y2.
|
||||
sa = dx12 * (y - y1);
|
||||
sb = dx02 * (y - y0);
|
||||
for(; y<=y2; y++) {
|
||||
a = x1 + sa / dy12;
|
||||
b = x0 + sb / dy02;
|
||||
sa += dx12;
|
||||
sb += dx02;
|
||||
/* longhand:
|
||||
a = x1 + (x2 - x1) * (y - y1) / (y2 - y1);
|
||||
b = x0 + (x2 - x0) * (y - y0) / (y2 - y0);
|
||||
*/
|
||||
if(a > b) swap(a,b);
|
||||
drawFastHLine(a, y, b-a+1, color);
|
||||
}
|
||||
}
|
||||
|
||||
void Adafruit_GFX::drawBitmap(int16_t x, int16_t y,
|
||||
const uint8_t *bitmap, int16_t w, int16_t h,
|
||||
uint16_t color) {
|
||||
|
||||
int16_t i, j, byteWidth = (w + 7) / 8;
|
||||
|
||||
for(j=0; j<h; j++) {
|
||||
for(i=0; i<w; i++ ) {
|
||||
if(pgm_read_byte(bitmap + j * byteWidth + i / 8) & (128 >> (i & 7))) {
|
||||
drawPixel(x+i, y+j, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Draw a 1-bit color bitmap at the specified x, y position from the
|
||||
// provided bitmap buffer (must be PROGMEM memory) using color as the
|
||||
// foreground color and bg as the background color.
|
||||
void Adafruit_GFX::drawBitmap(int16_t x, int16_t y,
|
||||
const uint8_t *bitmap, int16_t w, int16_t h,
|
||||
uint16_t color, uint16_t bg) {
|
||||
|
||||
int16_t i, j, byteWidth = (w + 7) / 8;
|
||||
|
||||
for(j=0; j<h; j++) {
|
||||
for(i=0; i<w; i++ ) {
|
||||
if(pgm_read_byte(bitmap + j * byteWidth + i / 8) & (128 >> (i & 7))) {
|
||||
drawPixel(x+i, y+j, color);
|
||||
}
|
||||
else {
|
||||
drawPixel(x+i, y+j, bg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Draw XBitMap Files (*.xbm), exported from GIMP,
|
||||
//Usage: Export from GIMP to *.xbm, rename *.xbm to *.c and open in editor.
|
||||
//C Array can be directly used with this function
|
||||
void Adafruit_GFX::drawXBitmap(int16_t x, int16_t y,
|
||||
const uint8_t *bitmap, int16_t w, int16_t h,
|
||||
uint16_t color) {
|
||||
|
||||
int16_t i, j, byteWidth = (w + 7) / 8;
|
||||
|
||||
for(j=0; j<h; j++) {
|
||||
for(i=0; i<w; i++ ) {
|
||||
if(pgm_read_byte(bitmap + j * byteWidth + i / 8) & (1 << (i % 8))) {
|
||||
drawPixel(x+i, y+j, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if ARDUINO >= 100
|
||||
size_t Adafruit_GFX::write(uint8_t c) {
|
||||
#else
|
||||
void Adafruit_GFX::write(uint8_t c) {
|
||||
#endif
|
||||
if (c == '\n') {
|
||||
cursor_y += textsize*8;
|
||||
cursor_x = 0;
|
||||
} else if (c == '\r') {
|
||||
// skip em
|
||||
} else {
|
||||
drawChar(cursor_x, cursor_y, c, textcolor, textbgcolor, textsize);
|
||||
cursor_x += textsize*6;
|
||||
if (wrap && (cursor_x > (_width - textsize*6))) {
|
||||
cursor_y += textsize*8;
|
||||
cursor_x = 0;
|
||||
}
|
||||
}
|
||||
#if ARDUINO >= 100
|
||||
return 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
// Draw a character
|
||||
void Adafruit_GFX::drawChar(int16_t x, int16_t y, unsigned char c,
|
||||
uint16_t color, uint16_t bg, uint8_t size) {
|
||||
|
||||
if((x >= _width) || // Clip right
|
||||
(y >= _height) || // Clip bottom
|
||||
((x + 6 * size - 1) < 0) || // Clip left
|
||||
((y + 8 * size - 1) < 0)) // Clip top
|
||||
return;
|
||||
|
||||
for (int8_t i=0; i<6; i++ ) {
|
||||
uint8_t line;
|
||||
if (i == 5)
|
||||
line = 0x0;
|
||||
else
|
||||
line = pgm_read_byte(font+(c*5)+i);
|
||||
for (int8_t j = 0; j<8; j++) {
|
||||
if (line & 0x1) {
|
||||
if (size == 1) // default size
|
||||
drawPixel(x+i, y+j, color);
|
||||
else { // big size
|
||||
fillRect(x+(i*size), y+(j*size), size, size, color);
|
||||
}
|
||||
} else if (bg != color) {
|
||||
if (size == 1) // default size
|
||||
drawPixel(x+i, y+j, bg);
|
||||
else { // big size
|
||||
fillRect(x+i*size, y+j*size, size, size, bg);
|
||||
}
|
||||
}
|
||||
line >>= 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Adafruit_GFX::setCursor(int16_t x, int16_t y) {
|
||||
cursor_x = x;
|
||||
cursor_y = y;
|
||||
}
|
||||
|
||||
void Adafruit_GFX::setTextSize(uint8_t s) {
|
||||
textsize = (s > 0) ? s : 1;
|
||||
}
|
||||
|
||||
void Adafruit_GFX::setTextColor(uint16_t c) {
|
||||
// For 'transparent' background, we'll set the bg
|
||||
// to the same as fg instead of using a flag
|
||||
textcolor = textbgcolor = c;
|
||||
}
|
||||
|
||||
void Adafruit_GFX::setTextColor(uint16_t c, uint16_t b) {
|
||||
textcolor = c;
|
||||
textbgcolor = b;
|
||||
}
|
||||
|
||||
void Adafruit_GFX::setTextWrap(boolean w) {
|
||||
wrap = w;
|
||||
}
|
||||
|
||||
uint8_t Adafruit_GFX::getRotation(void) const {
|
||||
return rotation;
|
||||
}
|
||||
|
||||
void Adafruit_GFX::setRotation(uint8_t x) {
|
||||
rotation = (x & 3);
|
||||
switch(rotation) {
|
||||
case 0:
|
||||
case 2:
|
||||
_width = WIDTH;
|
||||
_height = HEIGHT;
|
||||
break;
|
||||
case 1:
|
||||
case 3:
|
||||
_width = HEIGHT;
|
||||
_height = WIDTH;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Return the size of the display (per current rotation)
|
||||
int16_t Adafruit_GFX::width(void) const {
|
||||
return _width;
|
||||
}
|
||||
|
||||
int16_t Adafruit_GFX::height(void) const {
|
||||
return _height;
|
||||
}
|
||||
|
||||
void Adafruit_GFX::invertDisplay(boolean i) {
|
||||
// Do nothing, must be subclassed if supported
|
||||
}
|
||||
|
|
@ -1,90 +0,0 @@
|
|||
#ifndef _ADAFRUIT_GFX_H
|
||||
#define _ADAFRUIT_GFX_H
|
||||
|
||||
#if ARDUINO >= 100
|
||||
#include "Arduino.h"
|
||||
#include "Print.h"
|
||||
#else
|
||||
#include "WProgram.h"
|
||||
#endif
|
||||
|
||||
#define swap(a, b) { int16_t t = a; a = b; b = t; }
|
||||
|
||||
class Adafruit_GFX : public Print {
|
||||
|
||||
public:
|
||||
|
||||
Adafruit_GFX(int16_t w, int16_t h); // Constructor
|
||||
|
||||
// This MUST be defined by the subclass:
|
||||
virtual void drawPixel(int16_t x, int16_t y, uint16_t color) = 0;
|
||||
|
||||
// These MAY be overridden by the subclass to provide device-specific
|
||||
// optimized code. Otherwise 'generic' versions are used.
|
||||
virtual void
|
||||
drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t color),
|
||||
drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color),
|
||||
drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color),
|
||||
drawRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color),
|
||||
fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color),
|
||||
fillScreen(uint16_t color),
|
||||
invertDisplay(boolean i);
|
||||
|
||||
// These exist only with Adafruit_GFX (no subclass overrides)
|
||||
void
|
||||
drawCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color),
|
||||
drawCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t cornername,
|
||||
uint16_t color),
|
||||
fillCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color),
|
||||
fillCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t cornername,
|
||||
int16_t delta, uint16_t color),
|
||||
drawTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1,
|
||||
int16_t x2, int16_t y2, uint16_t color),
|
||||
fillTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1,
|
||||
int16_t x2, int16_t y2, uint16_t color),
|
||||
drawRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h,
|
||||
int16_t radius, uint16_t color),
|
||||
fillRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h,
|
||||
int16_t radius, uint16_t color),
|
||||
drawBitmap(int16_t x, int16_t y, const uint8_t *bitmap,
|
||||
int16_t w, int16_t h, uint16_t color),
|
||||
drawBitmap(int16_t x, int16_t y, const uint8_t *bitmap,
|
||||
int16_t w, int16_t h, uint16_t color, uint16_t bg),
|
||||
drawXBitmap(int16_t x, int16_t y, const uint8_t *bitmap,
|
||||
int16_t w, int16_t h, uint16_t color),
|
||||
drawChar(int16_t x, int16_t y, unsigned char c, uint16_t color,
|
||||
uint16_t bg, uint8_t size),
|
||||
setCursor(int16_t x, int16_t y),
|
||||
setTextColor(uint16_t c),
|
||||
setTextColor(uint16_t c, uint16_t bg),
|
||||
setTextSize(uint8_t s),
|
||||
setTextWrap(boolean w),
|
||||
setRotation(uint8_t r);
|
||||
|
||||
#if ARDUINO >= 100
|
||||
virtual size_t write(uint8_t);
|
||||
#else
|
||||
virtual void write(uint8_t);
|
||||
#endif
|
||||
|
||||
int16_t height(void) const;
|
||||
int16_t width(void) const;
|
||||
|
||||
uint8_t getRotation(void) const;
|
||||
|
||||
protected:
|
||||
const int16_t
|
||||
WIDTH, HEIGHT; // This is the 'raw' display w/h - never changes
|
||||
int16_t
|
||||
_width, _height, // Display w/h as modified by current rotation
|
||||
cursor_x, cursor_y;
|
||||
uint16_t
|
||||
textcolor, textbgcolor;
|
||||
uint8_t
|
||||
textsize,
|
||||
rotation;
|
||||
boolean
|
||||
wrap; // If set, 'wrap' text at right edge of display
|
||||
};
|
||||
|
||||
#endif // _ADAFRUIT_GFX_H
|
|
@ -1,773 +0,0 @@
|
|||
/*********************************************************************
|
||||
This is a library for our Monochrome OLEDs based on SSD1306 drivers
|
||||
|
||||
Pick one up today in the adafruit shop!
|
||||
------> http://www.adafruit.com/category/63_98
|
||||
|
||||
These displays use SPI to communicate, 4 or 5 pins are required to
|
||||
interface
|
||||
|
||||
Adafruit invests time and resources providing this open source code,
|
||||
please support Adafruit and open-source hardware by purchasing
|
||||
products from Adafruit!
|
||||
|
||||
Written by Limor Fried/Ladyada for Adafruit Industries.
|
||||
BSD license, check license.txt for more information
|
||||
All text above, and the splash screen below must be included in any redistribution
|
||||
*********************************************************************/
|
||||
|
||||
#include <avr/pgmspace.h>
|
||||
#ifndef __SAM3X8E__
|
||||
#include <util/delay.h>
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <Wire.h>
|
||||
|
||||
#include "Adafruit_GFX.h"
|
||||
#include "Adafruit_SSD1306.h"
|
||||
|
||||
// the memory buffer for the LCD
|
||||
|
||||
static uint8_t buffer[SSD1306_LCDHEIGHT * SSD1306_LCDWIDTH / 8] = {
|
||||
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, 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, 0x00, 0x00, 0x00, 0x80,
|
||||
0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x80, 0x80, 0xC0, 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, 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, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC, 0xF8, 0xE0, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80,
|
||||
0x80, 0x80, 0x00, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0xFF,
|
||||
#if (SSD1306_LCDHEIGHT * SSD1306_LCDWIDTH > 96*16)
|
||||
0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00,
|
||||
0x80, 0xFF, 0xFF, 0x80, 0x80, 0x00, 0x80, 0x80, 0x00, 0x80, 0x80, 0x80, 0x80, 0x00, 0x80, 0x80,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0x8C, 0x8E, 0x84, 0x00, 0x00, 0x80, 0xF8,
|
||||
0xF8, 0xF8, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xE0, 0xE0, 0xC0, 0x80,
|
||||
0x00, 0xE0, 0xFC, 0xFE, 0xFF, 0xFF, 0xFF, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0xFF, 0xC7, 0x01, 0x01,
|
||||
0x01, 0x01, 0x83, 0xFF, 0xFF, 0x00, 0x00, 0x7C, 0xFE, 0xC7, 0x01, 0x01, 0x01, 0x01, 0x83, 0xFF,
|
||||
0xFF, 0xFF, 0x00, 0x38, 0xFE, 0xC7, 0x83, 0x01, 0x01, 0x01, 0x83, 0xC7, 0xFF, 0xFF, 0x00, 0x00,
|
||||
0x01, 0xFF, 0xFF, 0x01, 0x01, 0x00, 0xFF, 0xFF, 0x07, 0x01, 0x01, 0x01, 0x00, 0x00, 0x7F, 0xFF,
|
||||
0x80, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x7F, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x01, 0xFF,
|
||||
0xFF, 0xFF, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x03, 0x0F, 0x3F, 0x7F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xE7, 0xC7, 0xC7, 0x8F,
|
||||
0x8F, 0x9F, 0xBF, 0xFF, 0xFF, 0xC3, 0xC0, 0xF0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0xFC, 0xFC,
|
||||
0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xF8, 0xF8, 0xF0, 0xF0, 0xE0, 0xC0, 0x00, 0x01, 0x03, 0x03, 0x03,
|
||||
0x03, 0x03, 0x01, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x03, 0x03, 0x03, 0x01, 0x01,
|
||||
0x03, 0x01, 0x00, 0x00, 0x00, 0x01, 0x03, 0x03, 0x03, 0x03, 0x01, 0x01, 0x03, 0x03, 0x00, 0x00,
|
||||
0x00, 0x03, 0x03, 0x00, 0x00, 0x00, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
|
||||
0x03, 0x03, 0x03, 0x03, 0x03, 0x01, 0x00, 0x00, 0x00, 0x01, 0x03, 0x01, 0x00, 0x00, 0x00, 0x03,
|
||||
0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
#if (SSD1306_LCDHEIGHT == 64)
|
||||
0x00, 0x00, 0x00, 0x80, 0xC0, 0xE0, 0xF0, 0xF9, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x3F, 0x1F, 0x0F,
|
||||
0x87, 0xC7, 0xF7, 0xFF, 0xFF, 0x1F, 0x1F, 0x3D, 0xFC, 0xF8, 0xF8, 0xF8, 0xF8, 0x7C, 0x7D, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x3F, 0x0F, 0x07, 0x00, 0x30, 0x30, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0xFE, 0xFE, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xC0, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x30, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0xC0, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x7F, 0x3F, 0x1F,
|
||||
0x0F, 0x07, 0x1F, 0x7F, 0xFF, 0xFF, 0xF8, 0xF8, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xF8, 0xE0,
|
||||
0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0xFE, 0x00, 0x00,
|
||||
0x00, 0xFC, 0xFE, 0xFC, 0x0C, 0x06, 0x06, 0x0E, 0xFC, 0xF8, 0x00, 0x00, 0xF0, 0xF8, 0x1C, 0x0E,
|
||||
0x06, 0x06, 0x06, 0x0C, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xFE, 0xFE, 0x00, 0x00, 0x00, 0x00, 0xFC,
|
||||
0xFE, 0xFC, 0x00, 0x18, 0x3C, 0x7E, 0x66, 0xE6, 0xCE, 0x84, 0x00, 0x00, 0x06, 0xFF, 0xFF, 0x06,
|
||||
0x06, 0xFC, 0xFE, 0xFC, 0x0C, 0x06, 0x06, 0x06, 0x00, 0x00, 0xFE, 0xFE, 0x00, 0x00, 0xC0, 0xF8,
|
||||
0xFC, 0x4E, 0x46, 0x46, 0x46, 0x4E, 0x7C, 0x78, 0x40, 0x18, 0x3C, 0x76, 0xE6, 0xCE, 0xCC, 0x80,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x01, 0x07, 0x0F, 0x1F, 0x1F, 0x3F, 0x3F, 0x3F, 0x3F, 0x1F, 0x0F, 0x03,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x00, 0x00,
|
||||
0x00, 0x0F, 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x00, 0x00, 0x03, 0x07, 0x0E, 0x0C,
|
||||
0x18, 0x18, 0x0C, 0x06, 0x0F, 0x0F, 0x0F, 0x00, 0x00, 0x01, 0x0F, 0x0E, 0x0C, 0x18, 0x0C, 0x0F,
|
||||
0x07, 0x01, 0x00, 0x04, 0x0E, 0x0C, 0x18, 0x0C, 0x0F, 0x07, 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x00,
|
||||
0x00, 0x0F, 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x07,
|
||||
0x07, 0x0C, 0x0C, 0x18, 0x1C, 0x0C, 0x06, 0x06, 0x00, 0x04, 0x0E, 0x0C, 0x18, 0x0C, 0x0F, 0x07,
|
||||
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, 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, 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, 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, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
#endif
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
|
||||
// the most basic function, set a single pixel
|
||||
void Adafruit_SSD1306::drawPixel(int16_t x, int16_t y, uint16_t color) {
|
||||
if ((x < 0) || (x >= width()) || (y < 0) || (y >= height()))
|
||||
return;
|
||||
|
||||
// check rotation, move pixel around if necessary
|
||||
switch (getRotation()) {
|
||||
case 1:
|
||||
swap(x, y);
|
||||
x = WIDTH - x - 1;
|
||||
break;
|
||||
case 2:
|
||||
x = WIDTH - x - 1;
|
||||
y = HEIGHT - y - 1;
|
||||
break;
|
||||
case 3:
|
||||
swap(x, y);
|
||||
y = HEIGHT - y - 1;
|
||||
break;
|
||||
}
|
||||
|
||||
// x is which column
|
||||
switch (color)
|
||||
{
|
||||
case WHITE: buffer[x+ (y/8)*SSD1306_LCDWIDTH] |= (1 << (y&7)); break;
|
||||
case BLACK: buffer[x+ (y/8)*SSD1306_LCDWIDTH] &= ~(1 << (y&7)); break;
|
||||
case INVERSE: buffer[x+ (y/8)*SSD1306_LCDWIDTH] ^= (1 << (y&7)); break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Adafruit_SSD1306::Adafruit_SSD1306(int8_t SID, int8_t SCLK, int8_t DC, int8_t RST, int8_t CS) : Adafruit_GFX(SSD1306_LCDWIDTH, SSD1306_LCDHEIGHT) {
|
||||
cs = CS;
|
||||
rst = RST;
|
||||
dc = DC;
|
||||
sclk = SCLK;
|
||||
sid = SID;
|
||||
hwSPI = false;
|
||||
}
|
||||
|
||||
// constructor for hardware SPI - we indicate DataCommand, ChipSelect, Reset
|
||||
Adafruit_SSD1306::Adafruit_SSD1306(int8_t DC, int8_t RST, int8_t CS) : Adafruit_GFX(SSD1306_LCDWIDTH, SSD1306_LCDHEIGHT) {
|
||||
dc = DC;
|
||||
rst = RST;
|
||||
cs = CS;
|
||||
hwSPI = true;
|
||||
}
|
||||
|
||||
// initializer for I2C - we only indicate the reset pin!
|
||||
Adafruit_SSD1306::Adafruit_SSD1306(int8_t reset) :
|
||||
Adafruit_GFX(SSD1306_LCDWIDTH, SSD1306_LCDHEIGHT) {
|
||||
sclk = dc = cs = sid = -1;
|
||||
rst = reset;
|
||||
}
|
||||
|
||||
|
||||
void Adafruit_SSD1306::begin(uint8_t vccstate, uint8_t i2caddr, bool reset) {
|
||||
_vccstate = vccstate;
|
||||
_i2caddr = i2caddr;
|
||||
|
||||
// set pin directions
|
||||
if (sid != -1){
|
||||
pinMode(dc, OUTPUT);
|
||||
pinMode(cs, OUTPUT);
|
||||
csport = portOutputRegister(digitalPinToPort(cs));
|
||||
cspinmask = digitalPinToBitMask(cs);
|
||||
dcport = portOutputRegister(digitalPinToPort(dc));
|
||||
dcpinmask = digitalPinToBitMask(dc);
|
||||
if (!hwSPI){
|
||||
// set pins for software-SPI
|
||||
pinMode(sid, OUTPUT);
|
||||
pinMode(sclk, OUTPUT);
|
||||
clkport = portOutputRegister(digitalPinToPort(sclk));
|
||||
clkpinmask = digitalPinToBitMask(sclk);
|
||||
mosiport = portOutputRegister(digitalPinToPort(sid));
|
||||
mosipinmask = digitalPinToBitMask(sid);
|
||||
}
|
||||
if (hwSPI){
|
||||
SPI.begin ();
|
||||
#ifdef __SAM3X8E__
|
||||
SPI.setClockDivider (9); // 9.3 MHz
|
||||
#else
|
||||
SPI.setClockDivider (SPI_CLOCK_DIV2); // 8 MHz
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// I2C Init
|
||||
Wire.begin();
|
||||
#ifdef __SAM3X8E__
|
||||
// Force 400 KHz I2C, rawr! (Uses pins 20, 21 for SDA, SCL)
|
||||
TWI1->TWI_CWGR = 0;
|
||||
TWI1->TWI_CWGR = ((VARIANT_MCK / (2 * 400000)) - 4) * 0x101;
|
||||
#else
|
||||
TWBR = 10; //Force 400 Khz on AVR
|
||||
#endif
|
||||
}
|
||||
|
||||
if (reset) {
|
||||
// Setup reset pin direction (used by both SPI and I2C)
|
||||
pinMode(rst, OUTPUT);
|
||||
digitalWrite(rst, HIGH);
|
||||
// VDD (3.3V) goes high at start, lets just chill for a ms
|
||||
delay(1);
|
||||
// bring reset low
|
||||
digitalWrite(rst, LOW);
|
||||
// wait 10ms
|
||||
delay(10);
|
||||
// bring out of reset
|
||||
digitalWrite(rst, HIGH);
|
||||
// turn on VCC (9V?)
|
||||
}
|
||||
|
||||
#if defined SSD1306_128_32
|
||||
// Init sequence for 128x32 OLED module
|
||||
ssd1306_command(SSD1306_DISPLAYOFF); // 0xAE
|
||||
ssd1306_command(SSD1306_SETDISPLAYCLOCKDIV); // 0xD5
|
||||
ssd1306_command(0x80); // the suggested ratio 0x80
|
||||
ssd1306_command(SSD1306_SETMULTIPLEX); // 0xA8
|
||||
ssd1306_command(0x1F);
|
||||
ssd1306_command(SSD1306_SETDISPLAYOFFSET); // 0xD3
|
||||
ssd1306_command(0x0); // no offset
|
||||
ssd1306_command(SSD1306_SETSTARTLINE | 0x0); // line #0
|
||||
ssd1306_command(SSD1306_CHARGEPUMP); // 0x8D
|
||||
if (vccstate == SSD1306_EXTERNALVCC)
|
||||
{ ssd1306_command(0x10); }
|
||||
else
|
||||
{ ssd1306_command(0x14); }
|
||||
ssd1306_command(SSD1306_MEMORYMODE); // 0x20
|
||||
ssd1306_command(0x00); // 0x0 act like ks0108
|
||||
ssd1306_command(SSD1306_SEGREMAP | 0x1);
|
||||
ssd1306_command(SSD1306_COMSCANDEC);
|
||||
ssd1306_command(SSD1306_SETCOMPINS); // 0xDA
|
||||
ssd1306_command(SSD1306_SETCOMPINS_V); //Speeduino modified. Value 0x02 is used for original adafruit displays. 0x012 is used for some others //ssd1306_command(0x012);//ssd1306_command(0x02);
|
||||
ssd1306_command(SSD1306_SETCONTRAST); // 0x81
|
||||
ssd1306_command(0x8F);
|
||||
ssd1306_command(SSD1306_SETPRECHARGE); // 0xd9
|
||||
if (vccstate == SSD1306_EXTERNALVCC)
|
||||
{ ssd1306_command(0x22); }
|
||||
else
|
||||
{ ssd1306_command(0xF1); }
|
||||
ssd1306_command(SSD1306_SETVCOMDETECT); // 0xDB
|
||||
ssd1306_command(0x40);
|
||||
ssd1306_command(SSD1306_DISPLAYALLON_RESUME); // 0xA4
|
||||
ssd1306_command(SSD1306_NORMALDISPLAY); // 0xA6
|
||||
#endif
|
||||
|
||||
#if defined SSD1306_128_64
|
||||
// Init sequence for 128x64 OLED module
|
||||
ssd1306_command(SSD1306_DISPLAYOFF); // 0xAE
|
||||
ssd1306_command(SSD1306_SETDISPLAYCLOCKDIV); // 0xD5
|
||||
ssd1306_command(0x80); // the suggested ratio 0x80
|
||||
ssd1306_command(SSD1306_SETMULTIPLEX); // 0xA8
|
||||
ssd1306_command(0x3F);
|
||||
ssd1306_command(SSD1306_SETDISPLAYOFFSET); // 0xD3
|
||||
ssd1306_command(0x0); // no offset
|
||||
ssd1306_command(SSD1306_SETSTARTLINE | 0x0); // line #0
|
||||
ssd1306_command(SSD1306_CHARGEPUMP); // 0x8D
|
||||
if (vccstate == SSD1306_EXTERNALVCC)
|
||||
{ ssd1306_command(0x10); }
|
||||
else
|
||||
{ ssd1306_command(0x14); }
|
||||
ssd1306_command(SSD1306_MEMORYMODE); // 0x20
|
||||
ssd1306_command(0x00); // 0x0 act like ks0108
|
||||
ssd1306_command(SSD1306_SEGREMAP | 0x1);
|
||||
ssd1306_command(SSD1306_COMSCANDEC);
|
||||
ssd1306_command(SSD1306_SETCOMPINS); // 0xDA
|
||||
ssd1306_command(SSD1306_SETCOMPINS_V);
|
||||
ssd1306_command(SSD1306_SETCONTRAST); // 0x81
|
||||
if (vccstate == SSD1306_EXTERNALVCC)
|
||||
{ ssd1306_command(0x9F); }
|
||||
else
|
||||
{ ssd1306_command(0xCF); }
|
||||
ssd1306_command(SSD1306_SETPRECHARGE); // 0xd9
|
||||
if (vccstate == SSD1306_EXTERNALVCC)
|
||||
{ ssd1306_command(0x22); }
|
||||
else
|
||||
{ ssd1306_command(0xF1); }
|
||||
ssd1306_command(SSD1306_SETVCOMDETECT); // 0xDB
|
||||
ssd1306_command(0x40);
|
||||
ssd1306_command(SSD1306_DISPLAYALLON_RESUME); // 0xA4
|
||||
ssd1306_command(SSD1306_NORMALDISPLAY); // 0xA6
|
||||
#endif
|
||||
|
||||
#if defined SSD1306_96_16
|
||||
// Init sequence for 96x16 OLED module
|
||||
ssd1306_command(SSD1306_DISPLAYOFF); // 0xAE
|
||||
ssd1306_command(SSD1306_SETDISPLAYCLOCKDIV); // 0xD5
|
||||
ssd1306_command(0x80); // the suggested ratio 0x80
|
||||
ssd1306_command(SSD1306_SETMULTIPLEX); // 0xA8
|
||||
ssd1306_command(0x0F);
|
||||
ssd1306_command(SSD1306_SETDISPLAYOFFSET); // 0xD3
|
||||
ssd1306_command(0x00); // no offset
|
||||
ssd1306_command(SSD1306_SETSTARTLINE | 0x0); // line #0
|
||||
ssd1306_command(SSD1306_CHARGEPUMP); // 0x8D
|
||||
if (vccstate == SSD1306_EXTERNALVCC)
|
||||
{ ssd1306_command(0x10); }
|
||||
else
|
||||
{ ssd1306_command(0x14); }
|
||||
ssd1306_command(SSD1306_MEMORYMODE); // 0x20
|
||||
ssd1306_command(0x00); // 0x0 act like ks0108
|
||||
ssd1306_command(SSD1306_SEGREMAP | 0x1);
|
||||
ssd1306_command(SSD1306_COMSCANDEC);
|
||||
ssd1306_command(SSD1306_SETCOMPINS); // 0xDA
|
||||
ssd1306_command(0x2); //ada x12
|
||||
ssd1306_command(SSD1306_SETCONTRAST); // 0x81
|
||||
if (vccstate == SSD1306_EXTERNALVCC)
|
||||
{ ssd1306_command(0x10); }
|
||||
else
|
||||
{ ssd1306_command(0xAF); }
|
||||
ssd1306_command(SSD1306_SETPRECHARGE); // 0xd9
|
||||
if (vccstate == SSD1306_EXTERNALVCC)
|
||||
{ ssd1306_command(0x22); }
|
||||
else
|
||||
{ ssd1306_command(0xF1); }
|
||||
ssd1306_command(SSD1306_SETVCOMDETECT); // 0xDB
|
||||
ssd1306_command(0x40);
|
||||
ssd1306_command(SSD1306_DISPLAYALLON_RESUME); // 0xA4
|
||||
ssd1306_command(SSD1306_NORMALDISPLAY); // 0xA6
|
||||
#endif
|
||||
|
||||
ssd1306_command(SSD1306_DISPLAYON);//--turn on oled panel
|
||||
}
|
||||
|
||||
|
||||
void Adafruit_SSD1306::invertDisplay(uint8_t i) {
|
||||
if (i) {
|
||||
ssd1306_command(SSD1306_INVERTDISPLAY);
|
||||
} else {
|
||||
ssd1306_command(SSD1306_NORMALDISPLAY);
|
||||
}
|
||||
}
|
||||
|
||||
void Adafruit_SSD1306::ssd1306_command(uint8_t c) {
|
||||
if (sid != -1)
|
||||
{
|
||||
// SPI
|
||||
//digitalWrite(cs, HIGH);
|
||||
*csport |= cspinmask;
|
||||
//digitalWrite(dc, LOW);
|
||||
*dcport &= ~dcpinmask;
|
||||
//digitalWrite(cs, LOW);
|
||||
*csport &= ~cspinmask;
|
||||
fastSPIwrite(c);
|
||||
//digitalWrite(cs, HIGH);
|
||||
*csport |= cspinmask;
|
||||
}
|
||||
else
|
||||
{
|
||||
// I2C
|
||||
uint8_t control = 0x00; // Co = 0, D/C = 0
|
||||
Wire.beginTransmission(_i2caddr);
|
||||
WIRE_WRITE(control);
|
||||
WIRE_WRITE(c);
|
||||
Wire.endTransmission();
|
||||
}
|
||||
}
|
||||
|
||||
// startscrollright
|
||||
// Activate a right handed scroll for rows start through stop
|
||||
// Hint, the display is 16 rows tall. To scroll the whole display, run:
|
||||
// display.scrollright(0x00, 0x0F)
|
||||
void Adafruit_SSD1306::startscrollright(uint8_t start, uint8_t stop){
|
||||
ssd1306_command(SSD1306_RIGHT_HORIZONTAL_SCROLL);
|
||||
ssd1306_command(0X00);
|
||||
ssd1306_command(start);
|
||||
ssd1306_command(0X00);
|
||||
ssd1306_command(stop);
|
||||
ssd1306_command(0X00);
|
||||
ssd1306_command(0XFF);
|
||||
ssd1306_command(SSD1306_ACTIVATE_SCROLL);
|
||||
}
|
||||
|
||||
// startscrollleft
|
||||
// Activate a right handed scroll for rows start through stop
|
||||
// Hint, the display is 16 rows tall. To scroll the whole display, run:
|
||||
// display.scrollright(0x00, 0x0F)
|
||||
void Adafruit_SSD1306::startscrollleft(uint8_t start, uint8_t stop){
|
||||
ssd1306_command(SSD1306_LEFT_HORIZONTAL_SCROLL);
|
||||
ssd1306_command(0X00);
|
||||
ssd1306_command(start);
|
||||
ssd1306_command(0X00);
|
||||
ssd1306_command(stop);
|
||||
ssd1306_command(0X00);
|
||||
ssd1306_command(0XFF);
|
||||
ssd1306_command(SSD1306_ACTIVATE_SCROLL);
|
||||
}
|
||||
|
||||
// startscrolldiagright
|
||||
// Activate a diagonal scroll for rows start through stop
|
||||
// Hint, the display is 16 rows tall. To scroll the whole display, run:
|
||||
// display.scrollright(0x00, 0x0F)
|
||||
void Adafruit_SSD1306::startscrolldiagright(uint8_t start, uint8_t stop){
|
||||
ssd1306_command(SSD1306_SET_VERTICAL_SCROLL_AREA);
|
||||
ssd1306_command(0X00);
|
||||
ssd1306_command(SSD1306_LCDHEIGHT);
|
||||
ssd1306_command(SSD1306_VERTICAL_AND_RIGHT_HORIZONTAL_SCROLL);
|
||||
ssd1306_command(0X00);
|
||||
ssd1306_command(start);
|
||||
ssd1306_command(0X00);
|
||||
ssd1306_command(stop);
|
||||
ssd1306_command(0X01);
|
||||
ssd1306_command(SSD1306_ACTIVATE_SCROLL);
|
||||
}
|
||||
|
||||
// startscrolldiagleft
|
||||
// Activate a diagonal scroll for rows start through stop
|
||||
// Hint, the display is 16 rows tall. To scroll the whole display, run:
|
||||
// display.scrollright(0x00, 0x0F)
|
||||
void Adafruit_SSD1306::startscrolldiagleft(uint8_t start, uint8_t stop){
|
||||
ssd1306_command(SSD1306_SET_VERTICAL_SCROLL_AREA);
|
||||
ssd1306_command(0X00);
|
||||
ssd1306_command(SSD1306_LCDHEIGHT);
|
||||
ssd1306_command(SSD1306_VERTICAL_AND_LEFT_HORIZONTAL_SCROLL);
|
||||
ssd1306_command(0X00);
|
||||
ssd1306_command(start);
|
||||
ssd1306_command(0X00);
|
||||
ssd1306_command(stop);
|
||||
ssd1306_command(0X01);
|
||||
ssd1306_command(SSD1306_ACTIVATE_SCROLL);
|
||||
}
|
||||
|
||||
void Adafruit_SSD1306::stopscroll(void){
|
||||
ssd1306_command(SSD1306_DEACTIVATE_SCROLL);
|
||||
}
|
||||
|
||||
// Dim the display
|
||||
// dim = true: display is dimmed
|
||||
// dim = false: display is normal
|
||||
void Adafruit_SSD1306::dim(boolean dim) {
|
||||
uint8_t contrast;
|
||||
|
||||
if (dim) {
|
||||
contrast = 0; // Dimmed display
|
||||
} else {
|
||||
if (_vccstate == SSD1306_EXTERNALVCC) {
|
||||
contrast = 0x9F;
|
||||
} else {
|
||||
contrast = 0xCF;
|
||||
}
|
||||
}
|
||||
// the range of contrast to too small to be really useful
|
||||
// it is useful to dim the display
|
||||
ssd1306_command(SSD1306_SETCONTRAST);
|
||||
ssd1306_command(contrast);
|
||||
}
|
||||
|
||||
void Adafruit_SSD1306::ssd1306_data(uint8_t c) {
|
||||
if (sid != -1)
|
||||
{
|
||||
// SPI
|
||||
//digitalWrite(cs, HIGH);
|
||||
*csport |= cspinmask;
|
||||
//digitalWrite(dc, HIGH);
|
||||
*dcport |= dcpinmask;
|
||||
//digitalWrite(cs, LOW);
|
||||
*csport &= ~cspinmask;
|
||||
fastSPIwrite(c);
|
||||
//digitalWrite(cs, HIGH);
|
||||
*csport |= cspinmask;
|
||||
}
|
||||
else
|
||||
{
|
||||
// I2C
|
||||
uint8_t control = 0x40; // Co = 0, D/C = 1
|
||||
Wire.beginTransmission(_i2caddr);
|
||||
WIRE_WRITE(control);
|
||||
WIRE_WRITE(c);
|
||||
Wire.endTransmission();
|
||||
}
|
||||
}
|
||||
|
||||
void Adafruit_SSD1306::display(void) {
|
||||
ssd1306_command(SSD1306_COLUMNADDR);
|
||||
ssd1306_command(0); // Column start address (0 = reset)
|
||||
ssd1306_command(SSD1306_LCDWIDTH-1); // Column end address (127 = reset)
|
||||
|
||||
ssd1306_command(SSD1306_PAGEADDR);
|
||||
ssd1306_command(0); // Page start address (0 = reset)
|
||||
#if SSD1306_LCDHEIGHT == 64
|
||||
ssd1306_command(7); // Page end address
|
||||
#endif
|
||||
#if SSD1306_LCDHEIGHT == 32
|
||||
ssd1306_command(3); // Page end address
|
||||
#endif
|
||||
#if SSD1306_LCDHEIGHT == 16
|
||||
ssd1306_command(1); // Page end address
|
||||
#endif
|
||||
|
||||
if (sid != -1)
|
||||
{
|
||||
// SPI
|
||||
*csport |= cspinmask;
|
||||
*dcport |= dcpinmask;
|
||||
*csport &= ~cspinmask;
|
||||
|
||||
for (uint16_t i=0; i<(SSD1306_LCDWIDTH*SSD1306_LCDHEIGHT/8); i++) {
|
||||
fastSPIwrite(buffer[i]);
|
||||
//ssd1306_data(buffer[i]);
|
||||
}
|
||||
*csport |= cspinmask;
|
||||
}
|
||||
else
|
||||
{
|
||||
// save I2C bitrate
|
||||
#ifndef __SAM3X8E__
|
||||
uint8_t twbrbackup = TWBR;
|
||||
TWBR = 12; // upgrade to 400KHz!
|
||||
#endif
|
||||
|
||||
//Serial.println(TWBR, DEC);
|
||||
//Serial.println(TWSR & 0x3, DEC);
|
||||
|
||||
// I2C
|
||||
for (uint16_t i=0; i<(SSD1306_LCDWIDTH*SSD1306_LCDHEIGHT/8); i++) {
|
||||
// send a bunch of data in one xmission
|
||||
Wire.beginTransmission(_i2caddr);
|
||||
WIRE_WRITE(0x40);
|
||||
for (uint8_t x=0; x<16; x++) {
|
||||
WIRE_WRITE(buffer[i]);
|
||||
i++;
|
||||
}
|
||||
i--;
|
||||
Wire.endTransmission();
|
||||
}
|
||||
#ifndef __SAM3X8E__
|
||||
TWBR = twbrbackup;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
// clear everything
|
||||
void Adafruit_SSD1306::clearDisplay(void) {
|
||||
memset(buffer, 0, (SSD1306_LCDWIDTH*SSD1306_LCDHEIGHT/8));
|
||||
}
|
||||
|
||||
|
||||
inline void Adafruit_SSD1306::fastSPIwrite(uint8_t d) {
|
||||
|
||||
if(hwSPI) {
|
||||
(void)SPI.transfer(d);
|
||||
} else {
|
||||
for(uint8_t bit = 0x80; bit; bit >>= 1) {
|
||||
*clkport &= ~clkpinmask;
|
||||
if(d & bit) *mosiport |= mosipinmask;
|
||||
else *mosiport &= ~mosipinmask;
|
||||
*clkport |= clkpinmask;
|
||||
}
|
||||
}
|
||||
//*csport |= cspinmask;
|
||||
}
|
||||
|
||||
void Adafruit_SSD1306::drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color) {
|
||||
boolean bSwap = false;
|
||||
switch(rotation) {
|
||||
case 0:
|
||||
// 0 degree rotation, do nothing
|
||||
break;
|
||||
case 1:
|
||||
// 90 degree rotation, swap x & y for rotation, then invert x
|
||||
bSwap = true;
|
||||
swap(x, y);
|
||||
x = WIDTH - x - 1;
|
||||
break;
|
||||
case 2:
|
||||
// 180 degree rotation, invert x and y - then shift y around for height.
|
||||
x = WIDTH - x - 1;
|
||||
y = HEIGHT - y - 1;
|
||||
x -= (w-1);
|
||||
break;
|
||||
case 3:
|
||||
// 270 degree rotation, swap x & y for rotation, then invert y and adjust y for w (not to become h)
|
||||
bSwap = true;
|
||||
swap(x, y);
|
||||
y = HEIGHT - y - 1;
|
||||
y -= (w-1);
|
||||
break;
|
||||
}
|
||||
|
||||
if(bSwap) {
|
||||
drawFastVLineInternal(x, y, w, color);
|
||||
} else {
|
||||
drawFastHLineInternal(x, y, w, color);
|
||||
}
|
||||
}
|
||||
|
||||
void Adafruit_SSD1306::drawFastHLineInternal(int16_t x, int16_t y, int16_t w, uint16_t color) {
|
||||
// Do bounds/limit checks
|
||||
if(y < 0 || y >= HEIGHT) { return; }
|
||||
|
||||
// make sure we don't try to draw below 0
|
||||
if(x < 0) {
|
||||
w += x;
|
||||
x = 0;
|
||||
}
|
||||
|
||||
// make sure we don't go off the edge of the display
|
||||
if( (x + w) > WIDTH) {
|
||||
w = (WIDTH - x);
|
||||
}
|
||||
|
||||
// if our width is now negative, punt
|
||||
if(w <= 0) { return; }
|
||||
|
||||
// set up the pointer for movement through the buffer
|
||||
register uint8_t *pBuf = buffer;
|
||||
// adjust the buffer pointer for the current row
|
||||
pBuf += ((y/8) * SSD1306_LCDWIDTH);
|
||||
// and offset x columns in
|
||||
pBuf += x;
|
||||
|
||||
register uint8_t mask = 1 << (y&7);
|
||||
|
||||
switch (color)
|
||||
{
|
||||
case WHITE: while(w--) { *pBuf++ |= mask; }; break;
|
||||
case BLACK: mask = ~mask; while(w--) { *pBuf++ &= mask; }; break;
|
||||
case INVERSE: while(w--) { *pBuf++ ^= mask; }; break;
|
||||
}
|
||||
}
|
||||
|
||||
void Adafruit_SSD1306::drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color) {
|
||||
bool bSwap = false;
|
||||
switch(rotation) {
|
||||
case 0:
|
||||
break;
|
||||
case 1:
|
||||
// 90 degree rotation, swap x & y for rotation, then invert x and adjust x for h (now to become w)
|
||||
bSwap = true;
|
||||
swap(x, y);
|
||||
x = WIDTH - x - 1;
|
||||
x -= (h-1);
|
||||
break;
|
||||
case 2:
|
||||
// 180 degree rotation, invert x and y - then shift y around for height.
|
||||
x = WIDTH - x - 1;
|
||||
y = HEIGHT - y - 1;
|
||||
y -= (h-1);
|
||||
break;
|
||||
case 3:
|
||||
// 270 degree rotation, swap x & y for rotation, then invert y
|
||||
bSwap = true;
|
||||
swap(x, y);
|
||||
y = HEIGHT - y - 1;
|
||||
break;
|
||||
}
|
||||
|
||||
if(bSwap) {
|
||||
drawFastHLineInternal(x, y, h, color);
|
||||
} else {
|
||||
drawFastVLineInternal(x, y, h, color);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Adafruit_SSD1306::drawFastVLineInternal(int16_t x, int16_t __y, int16_t __h, uint16_t color) {
|
||||
|
||||
// do nothing if we're off the left or right side of the screen
|
||||
if(x < 0 || x >= WIDTH) { return; }
|
||||
|
||||
// make sure we don't try to draw below 0
|
||||
if(__y < 0) {
|
||||
// __y is negative, this will subtract enough from __h to account for __y being 0
|
||||
__h += __y;
|
||||
__y = 0;
|
||||
|
||||
}
|
||||
|
||||
// make sure we don't go past the height of the display
|
||||
if( (__y + __h) > HEIGHT) {
|
||||
__h = (HEIGHT - __y);
|
||||
}
|
||||
|
||||
// if our height is now negative, punt
|
||||
if(__h <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// this display doesn't need ints for coordinates, use local byte registers for faster juggling
|
||||
register uint8_t y = __y;
|
||||
register uint8_t h = __h;
|
||||
|
||||
|
||||
// set up the pointer for fast movement through the buffer
|
||||
register uint8_t *pBuf = buffer;
|
||||
// adjust the buffer pointer for the current row
|
||||
pBuf += ((y/8) * SSD1306_LCDWIDTH);
|
||||
// and offset x columns in
|
||||
pBuf += x;
|
||||
|
||||
// do the first partial byte, if necessary - this requires some masking
|
||||
register uint8_t mod = (y&7);
|
||||
if(mod) {
|
||||
// mask off the high n bits we want to set
|
||||
mod = 8-mod;
|
||||
|
||||
// note - lookup table results in a nearly 10% performance improvement in fill* functions
|
||||
// register uint8_t mask = ~(0xFF >> (mod));
|
||||
static uint8_t premask[8] = {0x00, 0x80, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC, 0xFE };
|
||||
register uint8_t mask = premask[mod];
|
||||
|
||||
// adjust the mask if we're not going to reach the end of this byte
|
||||
if( h < mod) {
|
||||
mask &= (0XFF >> (mod-h));
|
||||
}
|
||||
|
||||
switch (color)
|
||||
{
|
||||
case WHITE: *pBuf |= mask; break;
|
||||
case BLACK: *pBuf &= ~mask; break;
|
||||
case INVERSE: *pBuf ^= mask; break;
|
||||
}
|
||||
|
||||
// fast exit if we're done here!
|
||||
if(h<mod) { return; }
|
||||
|
||||
h -= mod;
|
||||
|
||||
pBuf += SSD1306_LCDWIDTH;
|
||||
}
|
||||
|
||||
|
||||
// write solid bytes while we can - effectively doing 8 rows at a time
|
||||
if(h >= 8) {
|
||||
if (color == INVERSE) { // separate copy of the code so we don't impact performance of the black/white write version with an extra comparison per loop
|
||||
do {
|
||||
*pBuf=~(*pBuf);
|
||||
|
||||
// adjust the buffer forward 8 rows worth of data
|
||||
pBuf += SSD1306_LCDWIDTH;
|
||||
|
||||
// adjust h & y (there's got to be a faster way for me to do this, but this should still help a fair bit for now)
|
||||
h -= 8;
|
||||
} while(h >= 8);
|
||||
}
|
||||
else {
|
||||
// store a local value to work with
|
||||
register uint8_t val = (color == WHITE) ? 255 : 0;
|
||||
|
||||
do {
|
||||
// write our value in
|
||||
*pBuf = val;
|
||||
|
||||
// adjust the buffer forward 8 rows worth of data
|
||||
pBuf += SSD1306_LCDWIDTH;
|
||||
|
||||
// adjust h & y (there's got to be a faster way for me to do this, but this should still help a fair bit for now)
|
||||
h -= 8;
|
||||
} while(h >= 8);
|
||||
}
|
||||
}
|
||||
|
||||
// now do the final partial byte, if necessary
|
||||
if(h) {
|
||||
mod = h & 7;
|
||||
// this time we want to mask the low bits of the byte, vs the high bits we did above
|
||||
// register uint8_t mask = (1 << mod) - 1;
|
||||
// note - lookup table results in a nearly 10% performance improvement in fill* functions
|
||||
static uint8_t postmask[8] = {0x00, 0x01, 0x03, 0x07, 0x0F, 0x1F, 0x3F, 0x7F };
|
||||
register uint8_t mask = postmask[mod];
|
||||
switch (color)
|
||||
{
|
||||
case WHITE: *pBuf |= mask; break;
|
||||
case BLACK: *pBuf &= ~mask; break;
|
||||
case INVERSE: *pBuf ^= mask; break;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,172 +0,0 @@
|
|||
/*********************************************************************
|
||||
This is a library for our Monochrome OLEDs based on SSD1306 drivers
|
||||
|
||||
Pick one up today in the adafruit shop!
|
||||
------> http://www.adafruit.com/category/63_98
|
||||
|
||||
These displays use SPI to communicate, 4 or 5 pins are required to
|
||||
interface
|
||||
|
||||
Adafruit invests time and resources providing this open source code,
|
||||
please support Adafruit and open-source hardware by purchasing
|
||||
products from Adafruit!
|
||||
|
||||
Written by Limor Fried/Ladyada for Adafruit Industries.
|
||||
BSD license, check license.txt for more information
|
||||
All text above, and the splash screen must be included in any redistribution
|
||||
*********************************************************************/
|
||||
|
||||
#if ARDUINO >= 100
|
||||
#include "Arduino.h"
|
||||
#define WIRE_WRITE Wire.write
|
||||
#else
|
||||
#include "WProgram.h"
|
||||
#define WIRE_WRITE Wire.send
|
||||
#endif
|
||||
|
||||
#ifdef __SAM3X8E__
|
||||
typedef volatile RwReg PortReg;
|
||||
typedef uint32_t PortMask;
|
||||
#else
|
||||
typedef volatile uint8_t PortReg;
|
||||
typedef uint8_t PortMask;
|
||||
#endif
|
||||
|
||||
#include <SPI.h>
|
||||
#include "Adafruit_GFX.h"
|
||||
|
||||
#define BLACK 0
|
||||
#define WHITE 1
|
||||
#define INVERSE 2
|
||||
|
||||
#define SSD1306_I2C_ADDRESS 0x3C // 011110+SA0+RW - 0x3C or 0x3D
|
||||
// Address for 128x32 is 0x3C
|
||||
// Address for 128x64 is 0x3D (default) or 0x3C (if SA0 is grounded)
|
||||
|
||||
/*=========================================================================
|
||||
SSD1306 Displays
|
||||
-----------------------------------------------------------------------
|
||||
The driver is used in multiple displays (128x64, 128x32, etc.).
|
||||
Select the appropriate display below to create an appropriately
|
||||
sized framebuffer, etc.
|
||||
|
||||
SSD1306_128_64 128x64 pixel display
|
||||
|
||||
SSD1306_128_32 128x32 pixel display
|
||||
|
||||
SSD1306_96_16
|
||||
|
||||
-----------------------------------------------------------------------*/
|
||||
// #define SSD1306_128_64
|
||||
#define SSD1306_128_32
|
||||
// #define SSD1306_96_16
|
||||
/*=========================================================================*/
|
||||
|
||||
#if defined SSD1306_128_64 && defined SSD1306_128_32
|
||||
#error "Only one SSD1306 display can be specified at once in SSD1306.h"
|
||||
#endif
|
||||
#if !defined SSD1306_128_64 && !defined SSD1306_128_32 && !defined SSD1306_96_16
|
||||
#error "At least one SSD1306 display must be specified in SSD1306.h"
|
||||
#endif
|
||||
|
||||
#if defined SSD1306_128_64
|
||||
#define SSD1306_LCDWIDTH 128
|
||||
#define SSD1306_LCDHEIGHT 64
|
||||
#endif
|
||||
#if defined SSD1306_128_32
|
||||
#define SSD1306_LCDWIDTH 128
|
||||
#define SSD1306_LCDHEIGHT 32
|
||||
#endif
|
||||
#if defined SSD1306_96_16
|
||||
#define SSD1306_LCDWIDTH 96
|
||||
#define SSD1306_LCDHEIGHT 16
|
||||
#endif
|
||||
|
||||
#define SSD1306_SETCONTRAST 0x81
|
||||
#define SSD1306_DISPLAYALLON_RESUME 0xA4
|
||||
#define SSD1306_DISPLAYALLON 0xA5
|
||||
#define SSD1306_NORMALDISPLAY 0xA6
|
||||
#define SSD1306_INVERTDISPLAY 0xA7
|
||||
#define SSD1306_DISPLAYOFF 0xAE
|
||||
#define SSD1306_DISPLAYON 0xAF
|
||||
|
||||
#define SSD1306_SETDISPLAYOFFSET 0xD3
|
||||
#define SSD1306_SETCOMPINS 0xDA
|
||||
|
||||
#define SSD1306_SETVCOMDETECT 0xDB
|
||||
|
||||
#define SSD1306_SETDISPLAYCLOCKDIV 0xD5
|
||||
#define SSD1306_SETPRECHARGE 0xD9
|
||||
|
||||
#define SSD1306_SETMULTIPLEX 0xA8
|
||||
|
||||
#define SSD1306_SETLOWCOLUMN 0x00
|
||||
#define SSD1306_SETHIGHCOLUMN 0x10
|
||||
|
||||
#define SSD1306_SETSTARTLINE 0x40
|
||||
|
||||
#define SSD1306_MEMORYMODE 0x20
|
||||
#define SSD1306_COLUMNADDR 0x21
|
||||
#define SSD1306_PAGEADDR 0x22
|
||||
|
||||
#define SSD1306_COMSCANINC 0xC0
|
||||
#define SSD1306_COMSCANDEC 0xC8
|
||||
|
||||
#define SSD1306_SEGREMAP 0xA0
|
||||
|
||||
#define SSD1306_CHARGEPUMP 0x8D
|
||||
|
||||
#define SSD1306_EXTERNALVCC 0x1
|
||||
#define SSD1306_SWITCHCAPVCC 0x2
|
||||
|
||||
// Scrolling #defines
|
||||
#define SSD1306_ACTIVATE_SCROLL 0x2F
|
||||
#define SSD1306_DEACTIVATE_SCROLL 0x2E
|
||||
#define SSD1306_SET_VERTICAL_SCROLL_AREA 0xA3
|
||||
#define SSD1306_RIGHT_HORIZONTAL_SCROLL 0x26
|
||||
#define SSD1306_LEFT_HORIZONTAL_SCROLL 0x27
|
||||
#define SSD1306_VERTICAL_AND_RIGHT_HORIZONTAL_SCROLL 0x29
|
||||
#define SSD1306_VERTICAL_AND_LEFT_HORIZONTAL_SCROLL 0x2A
|
||||
|
||||
class Adafruit_SSD1306 : public Adafruit_GFX {
|
||||
public:
|
||||
Adafruit_SSD1306(int8_t SID, int8_t SCLK, int8_t DC, int8_t RST, int8_t CS);
|
||||
Adafruit_SSD1306(int8_t DC, int8_t RST, int8_t CS);
|
||||
Adafruit_SSD1306(int8_t RST);
|
||||
|
||||
void begin(uint8_t switchvcc = SSD1306_SWITCHCAPVCC, uint8_t i2caddr = SSD1306_I2C_ADDRESS, bool reset=true);
|
||||
void ssd1306_command(uint8_t c);
|
||||
void ssd1306_data(uint8_t c);
|
||||
|
||||
void clearDisplay(void);
|
||||
void invertDisplay(uint8_t i);
|
||||
void display();
|
||||
|
||||
void startscrollright(uint8_t start, uint8_t stop);
|
||||
void startscrollleft(uint8_t start, uint8_t stop);
|
||||
|
||||
void startscrolldiagright(uint8_t start, uint8_t stop);
|
||||
void startscrolldiagleft(uint8_t start, uint8_t stop);
|
||||
void stopscroll(void);
|
||||
|
||||
void dim(boolean dim);
|
||||
|
||||
void drawPixel(int16_t x, int16_t y, uint16_t color);
|
||||
|
||||
virtual void drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color);
|
||||
virtual void drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color);
|
||||
|
||||
byte SSD1306_SETCOMPINS_V;
|
||||
|
||||
private:
|
||||
int8_t _i2caddr, _vccstate, sid, sclk, dc, rst, cs;
|
||||
void fastSPIwrite(uint8_t c);
|
||||
|
||||
boolean hwSPI;
|
||||
PortReg *mosiport, *clkport, *csport, *dcport;
|
||||
PortMask mosipinmask, clkpinmask, cspinmask, dcpinmask;
|
||||
|
||||
inline void drawFastVLineInternal(int16_t x, int16_t y, int16_t h, uint16_t color) __attribute__((always_inline));
|
||||
inline void drawFastHLineInternal(int16_t x, int16_t y, int16_t w, uint16_t color) __attribute__((always_inline));
|
||||
|
||||
};
|
|
@ -1,24 +0,0 @@
|
|||
This is a library for our Monochrome OLEDs based on SSD1306 drivers
|
||||
|
||||
Pick one up today in the adafruit shop!
|
||||
------> http://www.adafruit.com/category/63_98
|
||||
|
||||
These displays use SPI to communicate, 4 or 5 pins are required to
|
||||
interface
|
||||
|
||||
Adafruit invests time and resources providing this open source code,
|
||||
please support Adafruit and open-source hardware by purchasing
|
||||
products from Adafruit!
|
||||
|
||||
Written by Limor Fried/Ladyada for Adafruit Industries.
|
||||
Scrolling code contributed by Michael Gregg
|
||||
BSD license, check license.txt for more information
|
||||
All text above must be included in any redistribution
|
||||
|
||||
To download. click the DOWNLOADS button in the top right corner, rename the uncompressed folder Adafruit_SSD1306. Check that the Adafruit_SSD1306 folder contains Adafruit_SSD1306.cpp and Adafruit_SSD1306.h
|
||||
|
||||
Place the Adafruit_SSD1306 library folder your <arduinosketchfolder>/libraries/ folder. You may need to create the libraries subfolder if its your first library. Restart the IDE.
|
||||
|
||||
You will also have to download the Adafruit GFX Graphics core which does all the circles, text, rectangles, etc. You can get it from
|
||||
https://github.com/adafruit/Adafruit-GFX-Library
|
||||
and download/install that library as well
|
|
@ -1,357 +0,0 @@
|
|||
/*********************************************************************
|
||||
This is an example for our Monochrome OLEDs based on SSD1306 drivers
|
||||
|
||||
Pick one up today in the adafruit shop!
|
||||
------> http://www.adafruit.com/category/63_98
|
||||
|
||||
This example is for a 128x32 size display using I2C to communicate
|
||||
3 pins are required to interface (2 I2C and one reset)
|
||||
|
||||
Adafruit invests time and resources providing this open source code,
|
||||
please support Adafruit and open-source hardware by purchasing
|
||||
products from Adafruit!
|
||||
|
||||
Written by Limor Fried/Ladyada for Adafruit Industries.
|
||||
BSD license, check license.txt for more information
|
||||
All text above, and the splash screen must be included in any redistribution
|
||||
*********************************************************************/
|
||||
|
||||
#include <SPI.h>
|
||||
#include <Wire.h>
|
||||
#include <Adafruit_GFX.h>
|
||||
#include <Adafruit_SSD1306.h>
|
||||
|
||||
#define OLED_RESET 4
|
||||
Adafruit_SSD1306 display(OLED_RESET);
|
||||
|
||||
#define NUMFLAKES 10
|
||||
#define XPOS 0
|
||||
#define YPOS 1
|
||||
#define DELTAY 2
|
||||
|
||||
|
||||
#define LOGO16_GLCD_HEIGHT 16
|
||||
#define LOGO16_GLCD_WIDTH 16
|
||||
static const unsigned char PROGMEM logo16_glcd_bmp[] =
|
||||
{ B00000000, B11000000,
|
||||
B00000001, B11000000,
|
||||
B00000001, B11000000,
|
||||
B00000011, B11100000,
|
||||
B11110011, B11100000,
|
||||
B11111110, B11111000,
|
||||
B01111110, B11111111,
|
||||
B00110011, B10011111,
|
||||
B00011111, B11111100,
|
||||
B00001101, B01110000,
|
||||
B00011011, B10100000,
|
||||
B00111111, B11100000,
|
||||
B00111111, B11110000,
|
||||
B01111100, B11110000,
|
||||
B01110000, B01110000,
|
||||
B00000000, B00110000 };
|
||||
|
||||
#if (SSD1306_LCDHEIGHT != 32)
|
||||
#error("Height incorrect, please fix Adafruit_SSD1306.h!");
|
||||
#endif
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// by default, we'll generate the high voltage from the 3.3v line internally! (neat!)
|
||||
display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // initialize with the I2C addr 0x3C (for the 128x32)
|
||||
// init done
|
||||
|
||||
// Show image buffer on the display hardware.
|
||||
// Since the buffer is intialized with an Adafruit splashscreen
|
||||
// internally, this will display the splashscreen.
|
||||
display.display();
|
||||
delay(2000);
|
||||
|
||||
// Clear the buffer.
|
||||
display.clearDisplay();
|
||||
|
||||
// draw a single pixel
|
||||
display.drawPixel(10, 10, WHITE);
|
||||
// Show the display buffer on the hardware.
|
||||
// NOTE: You _must_ call display after making any drawing commands
|
||||
// to make them visible on the display hardware!
|
||||
display.display();
|
||||
delay(2000);
|
||||
display.clearDisplay();
|
||||
|
||||
// draw many lines
|
||||
testdrawline();
|
||||
display.display();
|
||||
delay(2000);
|
||||
display.clearDisplay();
|
||||
|
||||
// draw rectangles
|
||||
testdrawrect();
|
||||
display.display();
|
||||
delay(2000);
|
||||
display.clearDisplay();
|
||||
|
||||
// draw multiple rectangles
|
||||
testfillrect();
|
||||
display.display();
|
||||
delay(2000);
|
||||
display.clearDisplay();
|
||||
|
||||
// draw mulitple circles
|
||||
testdrawcircle();
|
||||
display.display();
|
||||
delay(2000);
|
||||
display.clearDisplay();
|
||||
|
||||
// draw a white circle, 10 pixel radius
|
||||
display.fillCircle(display.width()/2, display.height()/2, 10, WHITE);
|
||||
display.display();
|
||||
delay(2000);
|
||||
display.clearDisplay();
|
||||
|
||||
testdrawroundrect();
|
||||
delay(2000);
|
||||
display.clearDisplay();
|
||||
|
||||
testfillroundrect();
|
||||
delay(2000);
|
||||
display.clearDisplay();
|
||||
|
||||
testdrawtriangle();
|
||||
delay(2000);
|
||||
display.clearDisplay();
|
||||
|
||||
testfilltriangle();
|
||||
delay(2000);
|
||||
display.clearDisplay();
|
||||
|
||||
// draw the first ~12 characters in the font
|
||||
testdrawchar();
|
||||
display.display();
|
||||
delay(2000);
|
||||
display.clearDisplay();
|
||||
|
||||
// draw scrolling text
|
||||
testscrolltext();
|
||||
delay(2000);
|
||||
display.clearDisplay();
|
||||
|
||||
// text display tests
|
||||
display.setTextSize(1);
|
||||
display.setTextColor(WHITE);
|
||||
display.setCursor(0,0);
|
||||
display.println("Hello, world!");
|
||||
display.setTextColor(BLACK, WHITE); // 'inverted' text
|
||||
display.println(3.141592);
|
||||
display.setTextSize(2);
|
||||
display.setTextColor(WHITE);
|
||||
display.print("0x"); display.println(0xDEADBEEF, HEX);
|
||||
display.display();
|
||||
delay(2000);
|
||||
|
||||
// miniature bitmap display
|
||||
display.clearDisplay();
|
||||
display.drawBitmap(30, 16, logo16_glcd_bmp, 16, 16, 1);
|
||||
display.display();
|
||||
|
||||
// invert the display
|
||||
display.invertDisplay(true);
|
||||
delay(1000);
|
||||
display.invertDisplay(false);
|
||||
delay(1000);
|
||||
|
||||
// draw a bitmap icon and 'animate' movement
|
||||
testdrawbitmap(logo16_glcd_bmp, LOGO16_GLCD_HEIGHT, LOGO16_GLCD_WIDTH);
|
||||
}
|
||||
|
||||
|
||||
void loop() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
void testdrawbitmap(const uint8_t *bitmap, uint8_t w, uint8_t h) {
|
||||
uint8_t icons[NUMFLAKES][3];
|
||||
|
||||
// initialize
|
||||
for (uint8_t f=0; f< NUMFLAKES; f++) {
|
||||
icons[f][XPOS] = random(display.width());
|
||||
icons[f][YPOS] = 0;
|
||||
icons[f][DELTAY] = random(5) + 1;
|
||||
|
||||
Serial.print("x: ");
|
||||
Serial.print(icons[f][XPOS], DEC);
|
||||
Serial.print(" y: ");
|
||||
Serial.print(icons[f][YPOS], DEC);
|
||||
Serial.print(" dy: ");
|
||||
Serial.println(icons[f][DELTAY], DEC);
|
||||
}
|
||||
|
||||
while (1) {
|
||||
// draw each icon
|
||||
for (uint8_t f=0; f< NUMFLAKES; f++) {
|
||||
display.drawBitmap(icons[f][XPOS], icons[f][YPOS], logo16_glcd_bmp, w, h, WHITE);
|
||||
}
|
||||
display.display();
|
||||
delay(200);
|
||||
|
||||
// then erase it + move it
|
||||
for (uint8_t f=0; f< NUMFLAKES; f++) {
|
||||
display.drawBitmap(icons[f][XPOS], icons[f][YPOS], logo16_glcd_bmp, w, h, BLACK);
|
||||
// move it
|
||||
icons[f][YPOS] += icons[f][DELTAY];
|
||||
// if its gone, reinit
|
||||
if (icons[f][YPOS] > display.height()) {
|
||||
icons[f][XPOS] = random(display.width());
|
||||
icons[f][YPOS] = 0;
|
||||
icons[f][DELTAY] = random(5) + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void testdrawchar(void) {
|
||||
display.setTextSize(1);
|
||||
display.setTextColor(WHITE);
|
||||
display.setCursor(0,0);
|
||||
|
||||
for (uint8_t i=0; i < 168; i++) {
|
||||
if (i == '\n') continue;
|
||||
display.write(i);
|
||||
if ((i > 0) && (i % 21 == 0))
|
||||
display.println();
|
||||
}
|
||||
display.display();
|
||||
}
|
||||
|
||||
void testdrawcircle(void) {
|
||||
for (int16_t i=0; i<display.height(); i+=2) {
|
||||
display.drawCircle(display.width()/2, display.height()/2, i, WHITE);
|
||||
display.display();
|
||||
}
|
||||
}
|
||||
|
||||
void testfillrect(void) {
|
||||
uint8_t color = 1;
|
||||
for (int16_t i=0; i<display.height()/2; i+=3) {
|
||||
// alternate colors
|
||||
display.fillRect(i, i, display.width()-i*2, display.height()-i*2, color%2);
|
||||
display.display();
|
||||
color++;
|
||||
}
|
||||
}
|
||||
|
||||
void testdrawtriangle(void) {
|
||||
for (int16_t i=0; i<min(display.width(),display.height())/2; i+=5) {
|
||||
display.drawTriangle(display.width()/2, display.height()/2-i,
|
||||
display.width()/2-i, display.height()/2+i,
|
||||
display.width()/2+i, display.height()/2+i, WHITE);
|
||||
display.display();
|
||||
}
|
||||
}
|
||||
|
||||
void testfilltriangle(void) {
|
||||
uint8_t color = WHITE;
|
||||
for (int16_t i=min(display.width(),display.height())/2; i>0; i-=5) {
|
||||
display.fillTriangle(display.width()/2, display.height()/2-i,
|
||||
display.width()/2-i, display.height()/2+i,
|
||||
display.width()/2+i, display.height()/2+i, WHITE);
|
||||
if (color == WHITE) color = BLACK;
|
||||
else color = WHITE;
|
||||
display.display();
|
||||
}
|
||||
}
|
||||
|
||||
void testdrawroundrect(void) {
|
||||
for (int16_t i=0; i<display.height()/2-2; i+=2) {
|
||||
display.drawRoundRect(i, i, display.width()-2*i, display.height()-2*i, display.height()/4, WHITE);
|
||||
display.display();
|
||||
}
|
||||
}
|
||||
|
||||
void testfillroundrect(void) {
|
||||
uint8_t color = WHITE;
|
||||
for (int16_t i=0; i<display.height()/2-2; i+=2) {
|
||||
display.fillRoundRect(i, i, display.width()-2*i, display.height()-2*i, display.height()/4, color);
|
||||
if (color == WHITE) color = BLACK;
|
||||
else color = WHITE;
|
||||
display.display();
|
||||
}
|
||||
}
|
||||
|
||||
void testdrawrect(void) {
|
||||
for (int16_t i=0; i<display.height()/2; i+=2) {
|
||||
display.drawRect(i, i, display.width()-2*i, display.height()-2*i, WHITE);
|
||||
display.display();
|
||||
}
|
||||
}
|
||||
|
||||
void testdrawline() {
|
||||
for (int16_t i=0; i<display.width(); i+=4) {
|
||||
display.drawLine(0, 0, i, display.height()-1, WHITE);
|
||||
display.display();
|
||||
}
|
||||
for (int16_t i=0; i<display.height(); i+=4) {
|
||||
display.drawLine(0, 0, display.width()-1, i, WHITE);
|
||||
display.display();
|
||||
}
|
||||
delay(250);
|
||||
|
||||
display.clearDisplay();
|
||||
for (int16_t i=0; i<display.width(); i+=4) {
|
||||
display.drawLine(0, display.height()-1, i, 0, WHITE);
|
||||
display.display();
|
||||
}
|
||||
for (int16_t i=display.height()-1; i>=0; i-=4) {
|
||||
display.drawLine(0, display.height()-1, display.width()-1, i, WHITE);
|
||||
display.display();
|
||||
}
|
||||
delay(250);
|
||||
|
||||
display.clearDisplay();
|
||||
for (int16_t i=display.width()-1; i>=0; i-=4) {
|
||||
display.drawLine(display.width()-1, display.height()-1, i, 0, WHITE);
|
||||
display.display();
|
||||
}
|
||||
for (int16_t i=display.height()-1; i>=0; i-=4) {
|
||||
display.drawLine(display.width()-1, display.height()-1, 0, i, WHITE);
|
||||
display.display();
|
||||
}
|
||||
delay(250);
|
||||
|
||||
display.clearDisplay();
|
||||
for (int16_t i=0; i<display.height(); i+=4) {
|
||||
display.drawLine(display.width()-1, 0, 0, i, WHITE);
|
||||
display.display();
|
||||
}
|
||||
for (int16_t i=0; i<display.width(); i+=4) {
|
||||
display.drawLine(display.width()-1, 0, i, display.height()-1, WHITE);
|
||||
display.display();
|
||||
}
|
||||
delay(250);
|
||||
}
|
||||
|
||||
void testscrolltext(void) {
|
||||
display.setTextSize(2);
|
||||
display.setTextColor(WHITE);
|
||||
display.setCursor(10,0);
|
||||
display.clearDisplay();
|
||||
display.println("scroll");
|
||||
display.display();
|
||||
|
||||
display.startscrollright(0x00, 0x0F);
|
||||
delay(2000);
|
||||
display.stopscroll();
|
||||
delay(1000);
|
||||
display.startscrollleft(0x00, 0x0F);
|
||||
delay(2000);
|
||||
display.stopscroll();
|
||||
delay(1000);
|
||||
display.startscrolldiagright(0x00, 0x07);
|
||||
delay(2000);
|
||||
display.startscrolldiagleft(0x00, 0x07);
|
||||
delay(2000);
|
||||
display.stopscroll();
|
||||
}
|
||||
|
|
@ -1,368 +0,0 @@
|
|||
/*********************************************************************
|
||||
This is an example for our Monochrome OLEDs based on SSD1306 drivers
|
||||
|
||||
Pick one up today in the adafruit shop!
|
||||
------> http://www.adafruit.com/category/63_98
|
||||
|
||||
This example is for a 128x32 size display using SPI to communicate
|
||||
4 or 5 pins are required to interface
|
||||
|
||||
Adafruit invests time and resources providing this open source code,
|
||||
please support Adafruit and open-source hardware by purchasing
|
||||
products from Adafruit!
|
||||
|
||||
Written by Limor Fried/Ladyada for Adafruit Industries.
|
||||
BSD license, check license.txt for more information
|
||||
All text above, and the splash screen must be included in any redistribution
|
||||
*********************************************************************/
|
||||
|
||||
#include <SPI.h>
|
||||
#include <Wire.h>
|
||||
#include <Adafruit_GFX.h>
|
||||
#include <Adafruit_SSD1306.h>
|
||||
|
||||
// If using software SPI (the default case):
|
||||
#define OLED_MOSI 9
|
||||
#define OLED_CLK 10
|
||||
#define OLED_DC 11
|
||||
#define OLED_CS 12
|
||||
#define OLED_RESET 13
|
||||
Adafruit_SSD1306 display(OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED_CS);
|
||||
|
||||
/* Uncomment this block to use hardware SPI
|
||||
#define OLED_DC 6
|
||||
#define OLED_CS 7
|
||||
#define OLED_RESET 8
|
||||
Adafruit_SSD1306 display(OLED_DC, OLED_RESET, OLED_CS);
|
||||
*/
|
||||
|
||||
#define NUMFLAKES 10
|
||||
#define XPOS 0
|
||||
#define YPOS 1
|
||||
#define DELTAY 2
|
||||
|
||||
#define LOGO16_GLCD_HEIGHT 16
|
||||
#define LOGO16_GLCD_WIDTH 16
|
||||
static const unsigned char PROGMEM logo16_glcd_bmp[] =
|
||||
{ B00000000, B11000000,
|
||||
B00000001, B11000000,
|
||||
B00000001, B11000000,
|
||||
B00000011, B11100000,
|
||||
B11110011, B11100000,
|
||||
B11111110, B11111000,
|
||||
B01111110, B11111111,
|
||||
B00110011, B10011111,
|
||||
B00011111, B11111100,
|
||||
B00001101, B01110000,
|
||||
B00011011, B10100000,
|
||||
B00111111, B11100000,
|
||||
B00111111, B11110000,
|
||||
B01111100, B11110000,
|
||||
B01110000, B01110000,
|
||||
B00000000, B00110000 };
|
||||
|
||||
#if (SSD1306_LCDHEIGHT != 32)
|
||||
#error("Height incorrect, please fix Adafruit_SSD1306.h!");
|
||||
#endif
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// by default, we'll generate the high voltage from the 3.3v line internally! (neat!)
|
||||
display.begin(SSD1306_SWITCHCAPVCC);
|
||||
// init done
|
||||
|
||||
// Show image buffer on the display hardware.
|
||||
// Since the buffer is intialized with an Adafruit splashscreen
|
||||
// internally, this will display the splashscreen.
|
||||
display.display();
|
||||
delay(2000);
|
||||
|
||||
// Clear the buffer.
|
||||
display.clearDisplay();
|
||||
|
||||
// draw a single pixel
|
||||
display.drawPixel(10, 10, WHITE);
|
||||
// Show the display buffer on the hardware.
|
||||
// NOTE: You _must_ call display after making any drawing commands
|
||||
// to make them visible on the display hardware!
|
||||
display.display();
|
||||
delay(2000);
|
||||
display.clearDisplay();
|
||||
|
||||
// draw many lines
|
||||
testdrawline();
|
||||
display.display();
|
||||
delay(2000);
|
||||
display.clearDisplay();
|
||||
|
||||
// draw rectangles
|
||||
testdrawrect();
|
||||
display.display();
|
||||
delay(2000);
|
||||
display.clearDisplay();
|
||||
|
||||
// draw multiple rectangles
|
||||
testfillrect();
|
||||
display.display();
|
||||
delay(2000);
|
||||
display.clearDisplay();
|
||||
|
||||
// draw mulitple circles
|
||||
testdrawcircle();
|
||||
display.display();
|
||||
delay(2000);
|
||||
display.clearDisplay();
|
||||
|
||||
// draw a white circle, 10 pixel radius
|
||||
display.fillCircle(display.width()/2, display.height()/2, 10, WHITE);
|
||||
display.display();
|
||||
delay(2000);
|
||||
display.clearDisplay();
|
||||
|
||||
testdrawroundrect();
|
||||
delay(2000);
|
||||
display.clearDisplay();
|
||||
|
||||
testfillroundrect();
|
||||
delay(2000);
|
||||
display.clearDisplay();
|
||||
|
||||
testdrawtriangle();
|
||||
delay(2000);
|
||||
display.clearDisplay();
|
||||
|
||||
testfilltriangle();
|
||||
delay(2000);
|
||||
display.clearDisplay();
|
||||
|
||||
// draw the first ~12 characters in the font
|
||||
testdrawchar();
|
||||
display.display();
|
||||
delay(2000);
|
||||
display.clearDisplay();
|
||||
|
||||
// draw scrolling text
|
||||
testscrolltext();
|
||||
delay(2000);
|
||||
display.clearDisplay();
|
||||
|
||||
// text display tests
|
||||
display.setTextSize(1);
|
||||
display.setTextColor(WHITE);
|
||||
display.setCursor(0,0);
|
||||
display.println("Hello, world!");
|
||||
display.setTextColor(BLACK, WHITE); // 'inverted' text
|
||||
display.println(3.141592);
|
||||
display.setTextSize(2);
|
||||
display.setTextColor(WHITE);
|
||||
display.print("0x"); display.println(0xDEADBEEF, HEX);
|
||||
display.display();
|
||||
delay(2000);
|
||||
|
||||
// miniature bitmap display
|
||||
display.clearDisplay();
|
||||
display.drawBitmap(30, 16, logo16_glcd_bmp, 16, 16, 1);
|
||||
display.display();
|
||||
|
||||
// invert the display
|
||||
display.invertDisplay(true);
|
||||
delay(1000);
|
||||
display.invertDisplay(false);
|
||||
delay(1000);
|
||||
|
||||
// draw a bitmap icon and 'animate' movement
|
||||
testdrawbitmap(logo16_glcd_bmp, LOGO16_GLCD_HEIGHT, LOGO16_GLCD_WIDTH);
|
||||
}
|
||||
|
||||
|
||||
void loop() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
void testdrawbitmap(const uint8_t *bitmap, uint8_t w, uint8_t h) {
|
||||
uint8_t icons[NUMFLAKES][3];
|
||||
|
||||
// initialize
|
||||
for (uint8_t f=0; f< NUMFLAKES; f++) {
|
||||
icons[f][XPOS] = random(display.width());
|
||||
icons[f][YPOS] = 0;
|
||||
icons[f][DELTAY] = random(5) + 1;
|
||||
|
||||
Serial.print("x: ");
|
||||
Serial.print(icons[f][XPOS], DEC);
|
||||
Serial.print(" y: ");
|
||||
Serial.print(icons[f][YPOS], DEC);
|
||||
Serial.print(" dy: ");
|
||||
Serial.println(icons[f][DELTAY], DEC);
|
||||
}
|
||||
|
||||
while (1) {
|
||||
// draw each icon
|
||||
for (uint8_t f=0; f< NUMFLAKES; f++) {
|
||||
display.drawBitmap(icons[f][XPOS], icons[f][YPOS], logo16_glcd_bmp, w, h, WHITE);
|
||||
}
|
||||
display.display();
|
||||
delay(200);
|
||||
|
||||
// then erase it + move it
|
||||
for (uint8_t f=0; f< NUMFLAKES; f++) {
|
||||
display.drawBitmap(icons[f][XPOS], icons[f][YPOS], logo16_glcd_bmp, w, h, BLACK);
|
||||
// move it
|
||||
icons[f][YPOS] += icons[f][DELTAY];
|
||||
// if its gone, reinit
|
||||
if (icons[f][YPOS] > display.height()) {
|
||||
icons[f][XPOS] = random(display.width());
|
||||
icons[f][YPOS] = 0;
|
||||
icons[f][DELTAY] = random(5) + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void testdrawchar(void) {
|
||||
display.setTextSize(1);
|
||||
display.setTextColor(WHITE);
|
||||
display.setCursor(0,0);
|
||||
|
||||
for (uint8_t i=0; i < 168; i++) {
|
||||
if (i == '\n') continue;
|
||||
display.write(i);
|
||||
if ((i > 0) && (i % 21 == 0))
|
||||
display.println();
|
||||
}
|
||||
display.display();
|
||||
}
|
||||
|
||||
void testdrawcircle(void) {
|
||||
for (int16_t i=0; i<display.height(); i+=2) {
|
||||
display.drawCircle(display.width()/2, display.height()/2, i, WHITE);
|
||||
display.display();
|
||||
}
|
||||
}
|
||||
|
||||
void testfillrect(void) {
|
||||
uint8_t color = 1;
|
||||
for (int16_t i=0; i<display.height()/2; i+=3) {
|
||||
// alternate colors
|
||||
display.fillRect(i, i, display.width()-i*2, display.height()-i*2, color%2);
|
||||
display.display();
|
||||
color++;
|
||||
}
|
||||
}
|
||||
|
||||
void testdrawtriangle(void) {
|
||||
for (int16_t i=0; i<min(display.width(),display.height())/2; i+=5) {
|
||||
display.drawTriangle(display.width()/2, display.height()/2-i,
|
||||
display.width()/2-i, display.height()/2+i,
|
||||
display.width()/2+i, display.height()/2+i, WHITE);
|
||||
display.display();
|
||||
}
|
||||
}
|
||||
|
||||
void testfilltriangle(void) {
|
||||
uint8_t color = WHITE;
|
||||
for (int16_t i=min(display.width(),display.height())/2; i>0; i-=5) {
|
||||
display.fillTriangle(display.width()/2, display.height()/2-i,
|
||||
display.width()/2-i, display.height()/2+i,
|
||||
display.width()/2+i, display.height()/2+i, WHITE);
|
||||
if (color == WHITE) color = BLACK;
|
||||
else color = WHITE;
|
||||
display.display();
|
||||
}
|
||||
}
|
||||
|
||||
void testdrawroundrect(void) {
|
||||
for (int16_t i=0; i<display.height()/2-2; i+=2) {
|
||||
display.drawRoundRect(i, i, display.width()-2*i, display.height()-2*i, display.height()/4, WHITE);
|
||||
display.display();
|
||||
}
|
||||
}
|
||||
|
||||
void testfillroundrect(void) {
|
||||
uint8_t color = WHITE;
|
||||
for (int16_t i=0; i<display.height()/2-2; i+=2) {
|
||||
display.fillRoundRect(i, i, display.width()-2*i, display.height()-2*i, display.height()/4, color);
|
||||
if (color == WHITE) color = BLACK;
|
||||
else color = WHITE;
|
||||
display.display();
|
||||
}
|
||||
}
|
||||
|
||||
void testdrawrect(void) {
|
||||
for (int16_t i=0; i<display.height()/2; i+=2) {
|
||||
display.drawRect(i, i, display.width()-2*i, display.height()-2*i, WHITE);
|
||||
display.display();
|
||||
}
|
||||
}
|
||||
|
||||
void testdrawline() {
|
||||
for (int16_t i=0; i<display.width(); i+=4) {
|
||||
display.drawLine(0, 0, i, display.height()-1, WHITE);
|
||||
display.display();
|
||||
}
|
||||
for (int16_t i=0; i<display.height(); i+=4) {
|
||||
display.drawLine(0, 0, display.width()-1, i, WHITE);
|
||||
display.display();
|
||||
}
|
||||
delay(250);
|
||||
|
||||
display.clearDisplay();
|
||||
for (int16_t i=0; i<display.width(); i+=4) {
|
||||
display.drawLine(0, display.height()-1, i, 0, WHITE);
|
||||
display.display();
|
||||
}
|
||||
for (int16_t i=display.height()-1; i>=0; i-=4) {
|
||||
display.drawLine(0, display.height()-1, display.width()-1, i, WHITE);
|
||||
display.display();
|
||||
}
|
||||
delay(250);
|
||||
|
||||
display.clearDisplay();
|
||||
for (int16_t i=display.width()-1; i>=0; i-=4) {
|
||||
display.drawLine(display.width()-1, display.height()-1, i, 0, WHITE);
|
||||
display.display();
|
||||
}
|
||||
for (int16_t i=display.height()-1; i>=0; i-=4) {
|
||||
display.drawLine(display.width()-1, display.height()-1, 0, i, WHITE);
|
||||
display.display();
|
||||
}
|
||||
delay(250);
|
||||
|
||||
display.clearDisplay();
|
||||
for (int16_t i=0; i<display.height(); i+=4) {
|
||||
display.drawLine(display.width()-1, 0, 0, i, WHITE);
|
||||
display.display();
|
||||
}
|
||||
for (int16_t i=0; i<display.width(); i+=4) {
|
||||
display.drawLine(display.width()-1, 0, i, display.height()-1, WHITE);
|
||||
display.display();
|
||||
}
|
||||
delay(250);
|
||||
}
|
||||
|
||||
void testscrolltext(void) {
|
||||
display.setTextSize(2);
|
||||
display.setTextColor(WHITE);
|
||||
display.setCursor(10,0);
|
||||
display.clearDisplay();
|
||||
display.println("scroll");
|
||||
display.display();
|
||||
|
||||
display.startscrollright(0x00, 0x0F);
|
||||
delay(2000);
|
||||
display.stopscroll();
|
||||
delay(1000);
|
||||
display.startscrollleft(0x00, 0x0F);
|
||||
delay(2000);
|
||||
display.stopscroll();
|
||||
delay(1000);
|
||||
display.startscrolldiagright(0x00, 0x07);
|
||||
delay(2000);
|
||||
display.startscrolldiagleft(0x00, 0x07);
|
||||
delay(2000);
|
||||
display.stopscroll();
|
||||
}
|
||||
|
|
@ -1,356 +0,0 @@
|
|||
/*********************************************************************
|
||||
This is an example for our Monochrome OLEDs based on SSD1306 drivers
|
||||
|
||||
Pick one up today in the adafruit shop!
|
||||
------> http://www.adafruit.com/category/63_98
|
||||
|
||||
This example is for a 128x64 size display using I2C to communicate
|
||||
3 pins are required to interface (2 I2C and one reset)
|
||||
|
||||
Adafruit invests time and resources providing this open source code,
|
||||
please support Adafruit and open-source hardware by purchasing
|
||||
products from Adafruit!
|
||||
|
||||
Written by Limor Fried/Ladyada for Adafruit Industries.
|
||||
BSD license, check license.txt for more information
|
||||
All text above, and the splash screen must be included in any redistribution
|
||||
*********************************************************************/
|
||||
|
||||
#include <SPI.h>
|
||||
#include <Wire.h>
|
||||
#include <Adafruit_GFX.h>
|
||||
#include <Adafruit_SSD1306.h>
|
||||
|
||||
#define OLED_RESET 4
|
||||
Adafruit_SSD1306 display(OLED_RESET);
|
||||
|
||||
#define NUMFLAKES 10
|
||||
#define XPOS 0
|
||||
#define YPOS 1
|
||||
#define DELTAY 2
|
||||
|
||||
|
||||
#define LOGO16_GLCD_HEIGHT 16
|
||||
#define LOGO16_GLCD_WIDTH 16
|
||||
static const unsigned char PROGMEM logo16_glcd_bmp[] =
|
||||
{ B00000000, B11000000,
|
||||
B00000001, B11000000,
|
||||
B00000001, B11000000,
|
||||
B00000011, B11100000,
|
||||
B11110011, B11100000,
|
||||
B11111110, B11111000,
|
||||
B01111110, B11111111,
|
||||
B00110011, B10011111,
|
||||
B00011111, B11111100,
|
||||
B00001101, B01110000,
|
||||
B00011011, B10100000,
|
||||
B00111111, B11100000,
|
||||
B00111111, B11110000,
|
||||
B01111100, B11110000,
|
||||
B01110000, B01110000,
|
||||
B00000000, B00110000 };
|
||||
|
||||
#if (SSD1306_LCDHEIGHT != 64)
|
||||
#error("Height incorrect, please fix Adafruit_SSD1306.h!");
|
||||
#endif
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// by default, we'll generate the high voltage from the 3.3v line internally! (neat!)
|
||||
display.begin(SSD1306_SWITCHCAPVCC, 0x3D); // initialize with the I2C addr 0x3D (for the 128x64)
|
||||
// init done
|
||||
|
||||
// Show image buffer on the display hardware.
|
||||
// Since the buffer is intialized with an Adafruit splashscreen
|
||||
// internally, this will display the splashscreen.
|
||||
display.display();
|
||||
delay(2000);
|
||||
|
||||
// Clear the buffer.
|
||||
display.clearDisplay();
|
||||
|
||||
// draw a single pixel
|
||||
display.drawPixel(10, 10, WHITE);
|
||||
// Show the display buffer on the hardware.
|
||||
// NOTE: You _must_ call display after making any drawing commands
|
||||
// to make them visible on the display hardware!
|
||||
display.display();
|
||||
delay(2000);
|
||||
display.clearDisplay();
|
||||
|
||||
// draw many lines
|
||||
testdrawline();
|
||||
display.display();
|
||||
delay(2000);
|
||||
display.clearDisplay();
|
||||
|
||||
// draw rectangles
|
||||
testdrawrect();
|
||||
display.display();
|
||||
delay(2000);
|
||||
display.clearDisplay();
|
||||
|
||||
// draw multiple rectangles
|
||||
testfillrect();
|
||||
display.display();
|
||||
delay(2000);
|
||||
display.clearDisplay();
|
||||
|
||||
// draw mulitple circles
|
||||
testdrawcircle();
|
||||
display.display();
|
||||
delay(2000);
|
||||
display.clearDisplay();
|
||||
|
||||
// draw a white circle, 10 pixel radius
|
||||
display.fillCircle(display.width()/2, display.height()/2, 10, WHITE);
|
||||
display.display();
|
||||
delay(2000);
|
||||
display.clearDisplay();
|
||||
|
||||
testdrawroundrect();
|
||||
delay(2000);
|
||||
display.clearDisplay();
|
||||
|
||||
testfillroundrect();
|
||||
delay(2000);
|
||||
display.clearDisplay();
|
||||
|
||||
testdrawtriangle();
|
||||
delay(2000);
|
||||
display.clearDisplay();
|
||||
|
||||
testfilltriangle();
|
||||
delay(2000);
|
||||
display.clearDisplay();
|
||||
|
||||
// draw the first ~12 characters in the font
|
||||
testdrawchar();
|
||||
display.display();
|
||||
delay(2000);
|
||||
display.clearDisplay();
|
||||
|
||||
// draw scrolling text
|
||||
testscrolltext();
|
||||
delay(2000);
|
||||
display.clearDisplay();
|
||||
|
||||
// text display tests
|
||||
display.setTextSize(1);
|
||||
display.setTextColor(WHITE);
|
||||
display.setCursor(0,0);
|
||||
display.println("Hello, world!");
|
||||
display.setTextColor(BLACK, WHITE); // 'inverted' text
|
||||
display.println(3.141592);
|
||||
display.setTextSize(2);
|
||||
display.setTextColor(WHITE);
|
||||
display.print("0x"); display.println(0xDEADBEEF, HEX);
|
||||
display.display();
|
||||
delay(2000);
|
||||
|
||||
// miniature bitmap display
|
||||
display.clearDisplay();
|
||||
display.drawBitmap(30, 16, logo16_glcd_bmp, 16, 16, 1);
|
||||
display.display();
|
||||
|
||||
// invert the display
|
||||
display.invertDisplay(true);
|
||||
delay(1000);
|
||||
display.invertDisplay(false);
|
||||
delay(1000);
|
||||
|
||||
// draw a bitmap icon and 'animate' movement
|
||||
testdrawbitmap(logo16_glcd_bmp, LOGO16_GLCD_HEIGHT, LOGO16_GLCD_WIDTH);
|
||||
}
|
||||
|
||||
|
||||
void loop() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
void testdrawbitmap(const uint8_t *bitmap, uint8_t w, uint8_t h) {
|
||||
uint8_t icons[NUMFLAKES][3];
|
||||
|
||||
// initialize
|
||||
for (uint8_t f=0; f< NUMFLAKES; f++) {
|
||||
icons[f][XPOS] = random(display.width());
|
||||
icons[f][YPOS] = 0;
|
||||
icons[f][DELTAY] = random(5) + 1;
|
||||
|
||||
Serial.print("x: ");
|
||||
Serial.print(icons[f][XPOS], DEC);
|
||||
Serial.print(" y: ");
|
||||
Serial.print(icons[f][YPOS], DEC);
|
||||
Serial.print(" dy: ");
|
||||
Serial.println(icons[f][DELTAY], DEC);
|
||||
}
|
||||
|
||||
while (1) {
|
||||
// draw each icon
|
||||
for (uint8_t f=0; f< NUMFLAKES; f++) {
|
||||
display.drawBitmap(icons[f][XPOS], icons[f][YPOS], logo16_glcd_bmp, w, h, WHITE);
|
||||
}
|
||||
display.display();
|
||||
delay(200);
|
||||
|
||||
// then erase it + move it
|
||||
for (uint8_t f=0; f< NUMFLAKES; f++) {
|
||||
display.drawBitmap(icons[f][XPOS], icons[f][YPOS], logo16_glcd_bmp, w, h, BLACK);
|
||||
// move it
|
||||
icons[f][YPOS] += icons[f][DELTAY];
|
||||
// if its gone, reinit
|
||||
if (icons[f][YPOS] > display.height()) {
|
||||
icons[f][XPOS] = random(display.width());
|
||||
icons[f][YPOS] = 0;
|
||||
icons[f][DELTAY] = random(5) + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void testdrawchar(void) {
|
||||
display.setTextSize(1);
|
||||
display.setTextColor(WHITE);
|
||||
display.setCursor(0,0);
|
||||
|
||||
for (uint8_t i=0; i < 168; i++) {
|
||||
if (i == '\n') continue;
|
||||
display.write(i);
|
||||
if ((i > 0) && (i % 21 == 0))
|
||||
display.println();
|
||||
}
|
||||
display.display();
|
||||
}
|
||||
|
||||
void testdrawcircle(void) {
|
||||
for (int16_t i=0; i<display.height(); i+=2) {
|
||||
display.drawCircle(display.width()/2, display.height()/2, i, WHITE);
|
||||
display.display();
|
||||
}
|
||||
}
|
||||
|
||||
void testfillrect(void) {
|
||||
uint8_t color = 1;
|
||||
for (int16_t i=0; i<display.height()/2; i+=3) {
|
||||
// alternate colors
|
||||
display.fillRect(i, i, display.width()-i*2, display.height()-i*2, color%2);
|
||||
display.display();
|
||||
color++;
|
||||
}
|
||||
}
|
||||
|
||||
void testdrawtriangle(void) {
|
||||
for (int16_t i=0; i<min(display.width(),display.height())/2; i+=5) {
|
||||
display.drawTriangle(display.width()/2, display.height()/2-i,
|
||||
display.width()/2-i, display.height()/2+i,
|
||||
display.width()/2+i, display.height()/2+i, WHITE);
|
||||
display.display();
|
||||
}
|
||||
}
|
||||
|
||||
void testfilltriangle(void) {
|
||||
uint8_t color = WHITE;
|
||||
for (int16_t i=min(display.width(),display.height())/2; i>0; i-=5) {
|
||||
display.fillTriangle(display.width()/2, display.height()/2-i,
|
||||
display.width()/2-i, display.height()/2+i,
|
||||
display.width()/2+i, display.height()/2+i, WHITE);
|
||||
if (color == WHITE) color = BLACK;
|
||||
else color = WHITE;
|
||||
display.display();
|
||||
}
|
||||
}
|
||||
|
||||
void testdrawroundrect(void) {
|
||||
for (int16_t i=0; i<display.height()/2-2; i+=2) {
|
||||
display.drawRoundRect(i, i, display.width()-2*i, display.height()-2*i, display.height()/4, WHITE);
|
||||
display.display();
|
||||
}
|
||||
}
|
||||
|
||||
void testfillroundrect(void) {
|
||||
uint8_t color = WHITE;
|
||||
for (int16_t i=0; i<display.height()/2-2; i+=2) {
|
||||
display.fillRoundRect(i, i, display.width()-2*i, display.height()-2*i, display.height()/4, color);
|
||||
if (color == WHITE) color = BLACK;
|
||||
else color = WHITE;
|
||||
display.display();
|
||||
}
|
||||
}
|
||||
|
||||
void testdrawrect(void) {
|
||||
for (int16_t i=0; i<display.height()/2; i+=2) {
|
||||
display.drawRect(i, i, display.width()-2*i, display.height()-2*i, WHITE);
|
||||
display.display();
|
||||
}
|
||||
}
|
||||
|
||||
void testdrawline() {
|
||||
for (int16_t i=0; i<display.width(); i+=4) {
|
||||
display.drawLine(0, 0, i, display.height()-1, WHITE);
|
||||
display.display();
|
||||
}
|
||||
for (int16_t i=0; i<display.height(); i+=4) {
|
||||
display.drawLine(0, 0, display.width()-1, i, WHITE);
|
||||
display.display();
|
||||
}
|
||||
delay(250);
|
||||
|
||||
display.clearDisplay();
|
||||
for (int16_t i=0; i<display.width(); i+=4) {
|
||||
display.drawLine(0, display.height()-1, i, 0, WHITE);
|
||||
display.display();
|
||||
}
|
||||
for (int16_t i=display.height()-1; i>=0; i-=4) {
|
||||
display.drawLine(0, display.height()-1, display.width()-1, i, WHITE);
|
||||
display.display();
|
||||
}
|
||||
delay(250);
|
||||
|
||||
display.clearDisplay();
|
||||
for (int16_t i=display.width()-1; i>=0; i-=4) {
|
||||
display.drawLine(display.width()-1, display.height()-1, i, 0, WHITE);
|
||||
display.display();
|
||||
}
|
||||
for (int16_t i=display.height()-1; i>=0; i-=4) {
|
||||
display.drawLine(display.width()-1, display.height()-1, 0, i, WHITE);
|
||||
display.display();
|
||||
}
|
||||
delay(250);
|
||||
|
||||
display.clearDisplay();
|
||||
for (int16_t i=0; i<display.height(); i+=4) {
|
||||
display.drawLine(display.width()-1, 0, 0, i, WHITE);
|
||||
display.display();
|
||||
}
|
||||
for (int16_t i=0; i<display.width(); i+=4) {
|
||||
display.drawLine(display.width()-1, 0, i, display.height()-1, WHITE);
|
||||
display.display();
|
||||
}
|
||||
delay(250);
|
||||
}
|
||||
|
||||
void testscrolltext(void) {
|
||||
display.setTextSize(2);
|
||||
display.setTextColor(WHITE);
|
||||
display.setCursor(10,0);
|
||||
display.clearDisplay();
|
||||
display.println("scroll");
|
||||
display.display();
|
||||
|
||||
display.startscrollright(0x00, 0x0F);
|
||||
delay(2000);
|
||||
display.stopscroll();
|
||||
delay(1000);
|
||||
display.startscrollleft(0x00, 0x0F);
|
||||
delay(2000);
|
||||
display.stopscroll();
|
||||
delay(1000);
|
||||
display.startscrolldiagright(0x00, 0x07);
|
||||
delay(2000);
|
||||
display.startscrolldiagleft(0x00, 0x07);
|
||||
delay(2000);
|
||||
display.stopscroll();
|
||||
}
|
|
@ -1,368 +0,0 @@
|
|||
/*********************************************************************
|
||||
This is an example for our Monochrome OLEDs based on SSD1306 drivers
|
||||
|
||||
Pick one up today in the adafruit shop!
|
||||
------> http://www.adafruit.com/category/63_98
|
||||
|
||||
This example is for a 128x64 size display using SPI to communicate
|
||||
4 or 5 pins are required to interface
|
||||
|
||||
Adafruit invests time and resources providing this open source code,
|
||||
please support Adafruit and open-source hardware by purchasing
|
||||
products from Adafruit!
|
||||
|
||||
Written by Limor Fried/Ladyada for Adafruit Industries.
|
||||
BSD license, check license.txt for more information
|
||||
All text above, and the splash screen must be included in any redistribution
|
||||
*********************************************************************/
|
||||
|
||||
#include <SPI.h>
|
||||
#include <Wire.h>
|
||||
#include <Adafruit_GFX.h>
|
||||
#include <Adafruit_SSD1306.h>
|
||||
|
||||
// If using software SPI (the default case):
|
||||
#define OLED_MOSI 9
|
||||
#define OLED_CLK 10
|
||||
#define OLED_DC 11
|
||||
#define OLED_CS 12
|
||||
#define OLED_RESET 13
|
||||
Adafruit_SSD1306 display(OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED_CS);
|
||||
|
||||
/* Uncomment this block to use hardware SPI
|
||||
#define OLED_DC 6
|
||||
#define OLED_CS 7
|
||||
#define OLED_RESET 8
|
||||
Adafruit_SSD1306 display(OLED_DC, OLED_RESET, OLED_CS);
|
||||
*/
|
||||
|
||||
#define NUMFLAKES 10
|
||||
#define XPOS 0
|
||||
#define YPOS 1
|
||||
#define DELTAY 2
|
||||
|
||||
#define LOGO16_GLCD_HEIGHT 16
|
||||
#define LOGO16_GLCD_WIDTH 16
|
||||
static const unsigned char PROGMEM logo16_glcd_bmp[] =
|
||||
{ B00000000, B11000000,
|
||||
B00000001, B11000000,
|
||||
B00000001, B11000000,
|
||||
B00000011, B11100000,
|
||||
B11110011, B11100000,
|
||||
B11111110, B11111000,
|
||||
B01111110, B11111111,
|
||||
B00110011, B10011111,
|
||||
B00011111, B11111100,
|
||||
B00001101, B01110000,
|
||||
B00011011, B10100000,
|
||||
B00111111, B11100000,
|
||||
B00111111, B11110000,
|
||||
B01111100, B11110000,
|
||||
B01110000, B01110000,
|
||||
B00000000, B00110000 };
|
||||
|
||||
#if (SSD1306_LCDHEIGHT != 64)
|
||||
#error("Height incorrect, please fix Adafruit_SSD1306.h!");
|
||||
#endif
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
// by default, we'll generate the high voltage from the 3.3v line internally! (neat!)
|
||||
display.begin(SSD1306_SWITCHCAPVCC);
|
||||
// init done
|
||||
|
||||
// Show image buffer on the display hardware.
|
||||
// Since the buffer is intialized with an Adafruit splashscreen
|
||||
// internally, this will display the splashscreen.
|
||||
display.display();
|
||||
delay(2000);
|
||||
|
||||
// Clear the buffer.
|
||||
display.clearDisplay();
|
||||
|
||||
// draw a single pixel
|
||||
display.drawPixel(10, 10, WHITE);
|
||||
// Show the display buffer on the hardware.
|
||||
// NOTE: You _must_ call display after making any drawing commands
|
||||
// to make them visible on the display hardware!
|
||||
display.display();
|
||||
delay(2000);
|
||||
display.clearDisplay();
|
||||
|
||||
// draw many lines
|
||||
testdrawline();
|
||||
display.display();
|
||||
delay(2000);
|
||||
display.clearDisplay();
|
||||
|
||||
// draw rectangles
|
||||
testdrawrect();
|
||||
display.display();
|
||||
delay(2000);
|
||||
display.clearDisplay();
|
||||
|
||||
// draw multiple rectangles
|
||||
testfillrect();
|
||||
display.display();
|
||||
delay(2000);
|
||||
display.clearDisplay();
|
||||
|
||||
// draw mulitple circles
|
||||
testdrawcircle();
|
||||
display.display();
|
||||
delay(2000);
|
||||
display.clearDisplay();
|
||||
|
||||
// draw a white circle, 10 pixel radius
|
||||
display.fillCircle(display.width()/2, display.height()/2, 10, WHITE);
|
||||
display.display();
|
||||
delay(2000);
|
||||
display.clearDisplay();
|
||||
|
||||
testdrawroundrect();
|
||||
delay(2000);
|
||||
display.clearDisplay();
|
||||
|
||||
testfillroundrect();
|
||||
delay(2000);
|
||||
display.clearDisplay();
|
||||
|
||||
testdrawtriangle();
|
||||
delay(2000);
|
||||
display.clearDisplay();
|
||||
|
||||
testfilltriangle();
|
||||
delay(2000);
|
||||
display.clearDisplay();
|
||||
|
||||
// draw the first ~12 characters in the font
|
||||
testdrawchar();
|
||||
display.display();
|
||||
delay(2000);
|
||||
display.clearDisplay();
|
||||
|
||||
// draw scrolling text
|
||||
testscrolltext();
|
||||
delay(2000);
|
||||
display.clearDisplay();
|
||||
|
||||
// text display tests
|
||||
display.setTextSize(1);
|
||||
display.setTextColor(WHITE);
|
||||
display.setCursor(0,0);
|
||||
display.println("Hello, world!");
|
||||
display.setTextColor(BLACK, WHITE); // 'inverted' text
|
||||
display.println(3.141592);
|
||||
display.setTextSize(2);
|
||||
display.setTextColor(WHITE);
|
||||
display.print("0x"); display.println(0xDEADBEEF, HEX);
|
||||
display.display();
|
||||
delay(2000);
|
||||
|
||||
// miniature bitmap display
|
||||
display.clearDisplay();
|
||||
display.drawBitmap(30, 16, logo16_glcd_bmp, 16, 16, 1);
|
||||
display.display();
|
||||
|
||||
// invert the display
|
||||
display.invertDisplay(true);
|
||||
delay(1000);
|
||||
display.invertDisplay(false);
|
||||
delay(1000);
|
||||
|
||||
// draw a bitmap icon and 'animate' movement
|
||||
testdrawbitmap(logo16_glcd_bmp, LOGO16_GLCD_HEIGHT, LOGO16_GLCD_WIDTH);
|
||||
}
|
||||
|
||||
|
||||
void loop() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
void testdrawbitmap(const uint8_t *bitmap, uint8_t w, uint8_t h) {
|
||||
uint8_t icons[NUMFLAKES][3];
|
||||
|
||||
// initialize
|
||||
for (uint8_t f=0; f< NUMFLAKES; f++) {
|
||||
icons[f][XPOS] = random(display.width());
|
||||
icons[f][YPOS] = 0;
|
||||
icons[f][DELTAY] = random(5) + 1;
|
||||
|
||||
Serial.print("x: ");
|
||||
Serial.print(icons[f][XPOS], DEC);
|
||||
Serial.print(" y: ");
|
||||
Serial.print(icons[f][YPOS], DEC);
|
||||
Serial.print(" dy: ");
|
||||
Serial.println(icons[f][DELTAY], DEC);
|
||||
}
|
||||
|
||||
while (1) {
|
||||
// draw each icon
|
||||
for (uint8_t f=0; f< NUMFLAKES; f++) {
|
||||
display.drawBitmap(icons[f][XPOS], icons[f][YPOS], logo16_glcd_bmp, w, h, WHITE);
|
||||
}
|
||||
display.display();
|
||||
delay(200);
|
||||
|
||||
// then erase it + move it
|
||||
for (uint8_t f=0; f< NUMFLAKES; f++) {
|
||||
display.drawBitmap(icons[f][XPOS], icons[f][YPOS], logo16_glcd_bmp, w, h, BLACK);
|
||||
// move it
|
||||
icons[f][YPOS] += icons[f][DELTAY];
|
||||
// if its gone, reinit
|
||||
if (icons[f][YPOS] > display.height()) {
|
||||
icons[f][XPOS] = random(display.width());
|
||||
icons[f][YPOS] = 0;
|
||||
icons[f][DELTAY] = random(5) + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void testdrawchar(void) {
|
||||
display.setTextSize(1);
|
||||
display.setTextColor(WHITE);
|
||||
display.setCursor(0,0);
|
||||
|
||||
for (uint8_t i=0; i < 168; i++) {
|
||||
if (i == '\n') continue;
|
||||
display.write(i);
|
||||
if ((i > 0) && (i % 21 == 0))
|
||||
display.println();
|
||||
}
|
||||
display.display();
|
||||
}
|
||||
|
||||
void testdrawcircle(void) {
|
||||
for (int16_t i=0; i<display.height(); i+=2) {
|
||||
display.drawCircle(display.width()/2, display.height()/2, i, WHITE);
|
||||
display.display();
|
||||
}
|
||||
}
|
||||
|
||||
void testfillrect(void) {
|
||||
uint8_t color = 1;
|
||||
for (int16_t i=0; i<display.height()/2; i+=3) {
|
||||
// alternate colors
|
||||
display.fillRect(i, i, display.width()-i*2, display.height()-i*2, color%2);
|
||||
display.display();
|
||||
color++;
|
||||
}
|
||||
}
|
||||
|
||||
void testdrawtriangle(void) {
|
||||
for (int16_t i=0; i<min(display.width(),display.height())/2; i+=5) {
|
||||
display.drawTriangle(display.width()/2, display.height()/2-i,
|
||||
display.width()/2-i, display.height()/2+i,
|
||||
display.width()/2+i, display.height()/2+i, WHITE);
|
||||
display.display();
|
||||
}
|
||||
}
|
||||
|
||||
void testfilltriangle(void) {
|
||||
uint8_t color = WHITE;
|
||||
for (int16_t i=min(display.width(),display.height())/2; i>0; i-=5) {
|
||||
display.fillTriangle(display.width()/2, display.height()/2-i,
|
||||
display.width()/2-i, display.height()/2+i,
|
||||
display.width()/2+i, display.height()/2+i, WHITE);
|
||||
if (color == WHITE) color = BLACK;
|
||||
else color = WHITE;
|
||||
display.display();
|
||||
}
|
||||
}
|
||||
|
||||
void testdrawroundrect(void) {
|
||||
for (int16_t i=0; i<display.height()/2-2; i+=2) {
|
||||
display.drawRoundRect(i, i, display.width()-2*i, display.height()-2*i, display.height()/4, WHITE);
|
||||
display.display();
|
||||
}
|
||||
}
|
||||
|
||||
void testfillroundrect(void) {
|
||||
uint8_t color = WHITE;
|
||||
for (int16_t i=0; i<display.height()/2-2; i+=2) {
|
||||
display.fillRoundRect(i, i, display.width()-2*i, display.height()-2*i, display.height()/4, color);
|
||||
if (color == WHITE) color = BLACK;
|
||||
else color = WHITE;
|
||||
display.display();
|
||||
}
|
||||
}
|
||||
|
||||
void testdrawrect(void) {
|
||||
for (int16_t i=0; i<display.height()/2; i+=2) {
|
||||
display.drawRect(i, i, display.width()-2*i, display.height()-2*i, WHITE);
|
||||
display.display();
|
||||
}
|
||||
}
|
||||
|
||||
void testdrawline() {
|
||||
for (int16_t i=0; i<display.width(); i+=4) {
|
||||
display.drawLine(0, 0, i, display.height()-1, WHITE);
|
||||
display.display();
|
||||
}
|
||||
for (int16_t i=0; i<display.height(); i+=4) {
|
||||
display.drawLine(0, 0, display.width()-1, i, WHITE);
|
||||
display.display();
|
||||
}
|
||||
delay(250);
|
||||
|
||||
display.clearDisplay();
|
||||
for (int16_t i=0; i<display.width(); i+=4) {
|
||||
display.drawLine(0, display.height()-1, i, 0, WHITE);
|
||||
display.display();
|
||||
}
|
||||
for (int16_t i=display.height()-1; i>=0; i-=4) {
|
||||
display.drawLine(0, display.height()-1, display.width()-1, i, WHITE);
|
||||
display.display();
|
||||
}
|
||||
delay(250);
|
||||
|
||||
display.clearDisplay();
|
||||
for (int16_t i=display.width()-1; i>=0; i-=4) {
|
||||
display.drawLine(display.width()-1, display.height()-1, i, 0, WHITE);
|
||||
display.display();
|
||||
}
|
||||
for (int16_t i=display.height()-1; i>=0; i-=4) {
|
||||
display.drawLine(display.width()-1, display.height()-1, 0, i, WHITE);
|
||||
display.display();
|
||||
}
|
||||
delay(250);
|
||||
|
||||
display.clearDisplay();
|
||||
for (int16_t i=0; i<display.height(); i+=4) {
|
||||
display.drawLine(display.width()-1, 0, 0, i, WHITE);
|
||||
display.display();
|
||||
}
|
||||
for (int16_t i=0; i<display.width(); i+=4) {
|
||||
display.drawLine(display.width()-1, 0, i, display.height()-1, WHITE);
|
||||
display.display();
|
||||
}
|
||||
delay(250);
|
||||
}
|
||||
|
||||
void testscrolltext(void) {
|
||||
display.setTextSize(2);
|
||||
display.setTextColor(WHITE);
|
||||
display.setCursor(10,0);
|
||||
display.clearDisplay();
|
||||
display.println("scroll");
|
||||
display.display();
|
||||
|
||||
display.startscrollright(0x00, 0x0F);
|
||||
delay(2000);
|
||||
display.stopscroll();
|
||||
delay(1000);
|
||||
display.startscrollleft(0x00, 0x0F);
|
||||
delay(2000);
|
||||
display.stopscroll();
|
||||
delay(1000);
|
||||
display.startscrolldiagright(0x00, 0x07);
|
||||
delay(2000);
|
||||
display.startscrolldiagleft(0x00, 0x07);
|
||||
delay(2000);
|
||||
display.stopscroll();
|
||||
}
|
||||
|
|
@ -1,270 +0,0 @@
|
|||
#ifndef FONT5X7_H
|
||||
#define FONT5X7_H
|
||||
|
||||
#ifdef __AVR__
|
||||
#include <avr/io.h>
|
||||
#include <avr/pgmspace.h>
|
||||
#else
|
||||
#define PROGMEM
|
||||
#endif
|
||||
|
||||
// Standard ASCII 5x7 font
|
||||
|
||||
static const unsigned char font[] PROGMEM = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x3E, 0x5B, 0x4F, 0x5B, 0x3E,
|
||||
0x3E, 0x6B, 0x4F, 0x6B, 0x3E,
|
||||
0x1C, 0x3E, 0x7C, 0x3E, 0x1C,
|
||||
0x18, 0x3C, 0x7E, 0x3C, 0x18,
|
||||
0x1C, 0x57, 0x7D, 0x57, 0x1C,
|
||||
0x1C, 0x5E, 0x7F, 0x5E, 0x1C,
|
||||
0x00, 0x18, 0x3C, 0x18, 0x00,
|
||||
0xFF, 0xE7, 0xC3, 0xE7, 0xFF,
|
||||
0x00, 0x18, 0x24, 0x18, 0x00,
|
||||
0xFF, 0xE7, 0xDB, 0xE7, 0xFF,
|
||||
0x30, 0x48, 0x3A, 0x06, 0x0E,
|
||||
0x26, 0x29, 0x79, 0x29, 0x26,
|
||||
0x40, 0x7F, 0x05, 0x05, 0x07,
|
||||
0x40, 0x7F, 0x05, 0x25, 0x3F,
|
||||
0x5A, 0x3C, 0xE7, 0x3C, 0x5A,
|
||||
0x7F, 0x3E, 0x1C, 0x1C, 0x08,
|
||||
0x08, 0x1C, 0x1C, 0x3E, 0x7F,
|
||||
0x14, 0x22, 0x7F, 0x22, 0x14,
|
||||
0x5F, 0x5F, 0x00, 0x5F, 0x5F,
|
||||
0x06, 0x09, 0x7F, 0x01, 0x7F,
|
||||
0x00, 0x66, 0x89, 0x95, 0x6A,
|
||||
0x60, 0x60, 0x60, 0x60, 0x60,
|
||||
0x94, 0xA2, 0xFF, 0xA2, 0x94,
|
||||
0x08, 0x04, 0x7E, 0x04, 0x08,
|
||||
0x10, 0x20, 0x7E, 0x20, 0x10,
|
||||
0x08, 0x08, 0x2A, 0x1C, 0x08,
|
||||
0x08, 0x1C, 0x2A, 0x08, 0x08,
|
||||
0x1E, 0x10, 0x10, 0x10, 0x10,
|
||||
0x0C, 0x1E, 0x0C, 0x1E, 0x0C,
|
||||
0x30, 0x38, 0x3E, 0x38, 0x30,
|
||||
0x06, 0x0E, 0x3E, 0x0E, 0x06,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x5F, 0x00, 0x00,
|
||||
0x00, 0x07, 0x00, 0x07, 0x00,
|
||||
0x14, 0x7F, 0x14, 0x7F, 0x14,
|
||||
0x24, 0x2A, 0x7F, 0x2A, 0x12,
|
||||
0x23, 0x13, 0x08, 0x64, 0x62,
|
||||
0x36, 0x49, 0x56, 0x20, 0x50,
|
||||
0x00, 0x08, 0x07, 0x03, 0x00,
|
||||
0x00, 0x1C, 0x22, 0x41, 0x00,
|
||||
0x00, 0x41, 0x22, 0x1C, 0x00,
|
||||
0x2A, 0x1C, 0x7F, 0x1C, 0x2A,
|
||||
0x08, 0x08, 0x3E, 0x08, 0x08,
|
||||
0x00, 0x80, 0x70, 0x30, 0x00,
|
||||
0x08, 0x08, 0x08, 0x08, 0x08,
|
||||
0x00, 0x00, 0x60, 0x60, 0x00,
|
||||
0x20, 0x10, 0x08, 0x04, 0x02,
|
||||
0x3E, 0x51, 0x49, 0x45, 0x3E,
|
||||
0x00, 0x42, 0x7F, 0x40, 0x00,
|
||||
0x72, 0x49, 0x49, 0x49, 0x46,
|
||||
0x21, 0x41, 0x49, 0x4D, 0x33,
|
||||
0x18, 0x14, 0x12, 0x7F, 0x10,
|
||||
0x27, 0x45, 0x45, 0x45, 0x39,
|
||||
0x3C, 0x4A, 0x49, 0x49, 0x31,
|
||||
0x41, 0x21, 0x11, 0x09, 0x07,
|
||||
0x36, 0x49, 0x49, 0x49, 0x36,
|
||||
0x46, 0x49, 0x49, 0x29, 0x1E,
|
||||
0x00, 0x00, 0x14, 0x00, 0x00,
|
||||
0x00, 0x40, 0x34, 0x00, 0x00,
|
||||
0x00, 0x08, 0x14, 0x22, 0x41,
|
||||
0x14, 0x14, 0x14, 0x14, 0x14,
|
||||
0x00, 0x41, 0x22, 0x14, 0x08,
|
||||
0x02, 0x01, 0x59, 0x09, 0x06,
|
||||
0x3E, 0x41, 0x5D, 0x59, 0x4E,
|
||||
0x7C, 0x12, 0x11, 0x12, 0x7C,
|
||||
0x7F, 0x49, 0x49, 0x49, 0x36,
|
||||
0x3E, 0x41, 0x41, 0x41, 0x22,
|
||||
0x7F, 0x41, 0x41, 0x41, 0x3E,
|
||||
0x7F, 0x49, 0x49, 0x49, 0x41,
|
||||
0x7F, 0x09, 0x09, 0x09, 0x01,
|
||||
0x3E, 0x41, 0x41, 0x51, 0x73,
|
||||
0x7F, 0x08, 0x08, 0x08, 0x7F,
|
||||
0x00, 0x41, 0x7F, 0x41, 0x00,
|
||||
0x20, 0x40, 0x41, 0x3F, 0x01,
|
||||
0x7F, 0x08, 0x14, 0x22, 0x41,
|
||||
0x7F, 0x40, 0x40, 0x40, 0x40,
|
||||
0x7F, 0x02, 0x1C, 0x02, 0x7F,
|
||||
0x7F, 0x04, 0x08, 0x10, 0x7F,
|
||||
0x3E, 0x41, 0x41, 0x41, 0x3E,
|
||||
0x7F, 0x09, 0x09, 0x09, 0x06,
|
||||
0x3E, 0x41, 0x51, 0x21, 0x5E,
|
||||
0x7F, 0x09, 0x19, 0x29, 0x46,
|
||||
0x26, 0x49, 0x49, 0x49, 0x32,
|
||||
0x03, 0x01, 0x7F, 0x01, 0x03,
|
||||
0x3F, 0x40, 0x40, 0x40, 0x3F,
|
||||
0x1F, 0x20, 0x40, 0x20, 0x1F,
|
||||
0x3F, 0x40, 0x38, 0x40, 0x3F,
|
||||
0x63, 0x14, 0x08, 0x14, 0x63,
|
||||
0x03, 0x04, 0x78, 0x04, 0x03,
|
||||
0x61, 0x59, 0x49, 0x4D, 0x43,
|
||||
0x00, 0x7F, 0x41, 0x41, 0x41,
|
||||
0x02, 0x04, 0x08, 0x10, 0x20,
|
||||
0x00, 0x41, 0x41, 0x41, 0x7F,
|
||||
0x04, 0x02, 0x01, 0x02, 0x04,
|
||||
0x40, 0x40, 0x40, 0x40, 0x40,
|
||||
0x00, 0x03, 0x07, 0x08, 0x00,
|
||||
0x20, 0x54, 0x54, 0x78, 0x40,
|
||||
0x7F, 0x28, 0x44, 0x44, 0x38,
|
||||
0x38, 0x44, 0x44, 0x44, 0x28,
|
||||
0x38, 0x44, 0x44, 0x28, 0x7F,
|
||||
0x38, 0x54, 0x54, 0x54, 0x18,
|
||||
0x00, 0x08, 0x7E, 0x09, 0x02,
|
||||
0x18, 0xA4, 0xA4, 0x9C, 0x78,
|
||||
0x7F, 0x08, 0x04, 0x04, 0x78,
|
||||
0x00, 0x44, 0x7D, 0x40, 0x00,
|
||||
0x20, 0x40, 0x40, 0x3D, 0x00,
|
||||
0x7F, 0x10, 0x28, 0x44, 0x00,
|
||||
0x00, 0x41, 0x7F, 0x40, 0x00,
|
||||
0x7C, 0x04, 0x78, 0x04, 0x78,
|
||||
0x7C, 0x08, 0x04, 0x04, 0x78,
|
||||
0x38, 0x44, 0x44, 0x44, 0x38,
|
||||
0xFC, 0x18, 0x24, 0x24, 0x18,
|
||||
0x18, 0x24, 0x24, 0x18, 0xFC,
|
||||
0x7C, 0x08, 0x04, 0x04, 0x08,
|
||||
0x48, 0x54, 0x54, 0x54, 0x24,
|
||||
0x04, 0x04, 0x3F, 0x44, 0x24,
|
||||
0x3C, 0x40, 0x40, 0x20, 0x7C,
|
||||
0x1C, 0x20, 0x40, 0x20, 0x1C,
|
||||
0x3C, 0x40, 0x30, 0x40, 0x3C,
|
||||
0x44, 0x28, 0x10, 0x28, 0x44,
|
||||
0x4C, 0x90, 0x90, 0x90, 0x7C,
|
||||
0x44, 0x64, 0x54, 0x4C, 0x44,
|
||||
0x00, 0x08, 0x36, 0x41, 0x00,
|
||||
0x00, 0x00, 0x77, 0x00, 0x00,
|
||||
0x00, 0x41, 0x36, 0x08, 0x00,
|
||||
0x02, 0x01, 0x02, 0x04, 0x02,
|
||||
0x3C, 0x26, 0x23, 0x26, 0x3C,
|
||||
0x1E, 0xA1, 0xA1, 0x61, 0x12,
|
||||
0x3A, 0x40, 0x40, 0x20, 0x7A,
|
||||
0x38, 0x54, 0x54, 0x55, 0x59,
|
||||
0x21, 0x55, 0x55, 0x79, 0x41,
|
||||
0x22, 0x54, 0x54, 0x78, 0x42, // a-umlaut
|
||||
0x21, 0x55, 0x54, 0x78, 0x40,
|
||||
0x20, 0x54, 0x55, 0x79, 0x40,
|
||||
0x0C, 0x1E, 0x52, 0x72, 0x12,
|
||||
0x39, 0x55, 0x55, 0x55, 0x59,
|
||||
0x39, 0x54, 0x54, 0x54, 0x59,
|
||||
0x39, 0x55, 0x54, 0x54, 0x58,
|
||||
0x00, 0x00, 0x45, 0x7C, 0x41,
|
||||
0x00, 0x02, 0x45, 0x7D, 0x42,
|
||||
0x00, 0x01, 0x45, 0x7C, 0x40,
|
||||
0x7D, 0x12, 0x11, 0x12, 0x7D, // A-umlaut
|
||||
0xF0, 0x28, 0x25, 0x28, 0xF0,
|
||||
0x7C, 0x54, 0x55, 0x45, 0x00,
|
||||
0x20, 0x54, 0x54, 0x7C, 0x54,
|
||||
0x7C, 0x0A, 0x09, 0x7F, 0x49,
|
||||
0x32, 0x49, 0x49, 0x49, 0x32,
|
||||
0x3A, 0x44, 0x44, 0x44, 0x3A, // o-umlaut
|
||||
0x32, 0x4A, 0x48, 0x48, 0x30,
|
||||
0x3A, 0x41, 0x41, 0x21, 0x7A,
|
||||
0x3A, 0x42, 0x40, 0x20, 0x78,
|
||||
0x00, 0x9D, 0xA0, 0xA0, 0x7D,
|
||||
0x3D, 0x42, 0x42, 0x42, 0x3D, // O-umlaut
|
||||
0x3D, 0x40, 0x40, 0x40, 0x3D,
|
||||
0x3C, 0x24, 0xFF, 0x24, 0x24,
|
||||
0x48, 0x7E, 0x49, 0x43, 0x66,
|
||||
0x2B, 0x2F, 0xFC, 0x2F, 0x2B,
|
||||
0xFF, 0x09, 0x29, 0xF6, 0x20,
|
||||
0xC0, 0x88, 0x7E, 0x09, 0x03,
|
||||
0x20, 0x54, 0x54, 0x79, 0x41,
|
||||
0x00, 0x00, 0x44, 0x7D, 0x41,
|
||||
0x30, 0x48, 0x48, 0x4A, 0x32,
|
||||
0x38, 0x40, 0x40, 0x22, 0x7A,
|
||||
0x00, 0x7A, 0x0A, 0x0A, 0x72,
|
||||
0x7D, 0x0D, 0x19, 0x31, 0x7D,
|
||||
0x26, 0x29, 0x29, 0x2F, 0x28,
|
||||
0x26, 0x29, 0x29, 0x29, 0x26,
|
||||
0x30, 0x48, 0x4D, 0x40, 0x20,
|
||||
0x38, 0x08, 0x08, 0x08, 0x08,
|
||||
0x08, 0x08, 0x08, 0x08, 0x38,
|
||||
0x2F, 0x10, 0xC8, 0xAC, 0xBA,
|
||||
0x2F, 0x10, 0x28, 0x34, 0xFA,
|
||||
0x00, 0x00, 0x7B, 0x00, 0x00,
|
||||
0x08, 0x14, 0x2A, 0x14, 0x22,
|
||||
0x22, 0x14, 0x2A, 0x14, 0x08,
|
||||
0xAA, 0x00, 0x55, 0x00, 0xAA,
|
||||
0xAA, 0x55, 0xAA, 0x55, 0xAA,
|
||||
0x00, 0x00, 0x00, 0xFF, 0x00,
|
||||
0x10, 0x10, 0x10, 0xFF, 0x00,
|
||||
0x14, 0x14, 0x14, 0xFF, 0x00,
|
||||
0x10, 0x10, 0xFF, 0x00, 0xFF,
|
||||
0x10, 0x10, 0xF0, 0x10, 0xF0,
|
||||
0x14, 0x14, 0x14, 0xFC, 0x00,
|
||||
0x14, 0x14, 0xF7, 0x00, 0xFF,
|
||||
0x00, 0x00, 0xFF, 0x00, 0xFF,
|
||||
0x14, 0x14, 0xF4, 0x04, 0xFC,
|
||||
0x14, 0x14, 0x17, 0x10, 0x1F,
|
||||
0x10, 0x10, 0x1F, 0x10, 0x1F,
|
||||
0x14, 0x14, 0x14, 0x1F, 0x00,
|
||||
0x10, 0x10, 0x10, 0xF0, 0x00,
|
||||
0x00, 0x00, 0x00, 0x1F, 0x10,
|
||||
0x10, 0x10, 0x10, 0x1F, 0x10,
|
||||
0x10, 0x10, 0x10, 0xF0, 0x10,
|
||||
0x00, 0x00, 0x00, 0xFF, 0x10,
|
||||
0x10, 0x10, 0x10, 0x10, 0x10,
|
||||
0x10, 0x10, 0x10, 0xFF, 0x10,
|
||||
0x00, 0x00, 0x00, 0xFF, 0x14,
|
||||
0x00, 0x00, 0xFF, 0x00, 0xFF,
|
||||
0x00, 0x00, 0x1F, 0x10, 0x17,
|
||||
0x00, 0x00, 0xFC, 0x04, 0xF4,
|
||||
0x14, 0x14, 0x17, 0x10, 0x17,
|
||||
0x14, 0x14, 0xF4, 0x04, 0xF4,
|
||||
0x00, 0x00, 0xFF, 0x00, 0xF7,
|
||||
0x14, 0x14, 0x14, 0x14, 0x14,
|
||||
0x14, 0x14, 0xF7, 0x00, 0xF7,
|
||||
0x14, 0x14, 0x14, 0x17, 0x14,
|
||||
0x10, 0x10, 0x1F, 0x10, 0x1F,
|
||||
0x14, 0x14, 0x14, 0xF4, 0x14,
|
||||
0x10, 0x10, 0xF0, 0x10, 0xF0,
|
||||
0x00, 0x00, 0x1F, 0x10, 0x1F,
|
||||
0x00, 0x00, 0x00, 0x1F, 0x14,
|
||||
0x00, 0x00, 0x00, 0xFC, 0x14,
|
||||
0x00, 0x00, 0xF0, 0x10, 0xF0,
|
||||
0x10, 0x10, 0xFF, 0x10, 0xFF,
|
||||
0x14, 0x14, 0x14, 0xFF, 0x14,
|
||||
0x10, 0x10, 0x10, 0x1F, 0x00,
|
||||
0x00, 0x00, 0x00, 0xF0, 0x10,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xF0, 0xF0, 0xF0, 0xF0, 0xF0,
|
||||
0xFF, 0xFF, 0xFF, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0xFF, 0xFF,
|
||||
0x0F, 0x0F, 0x0F, 0x0F, 0x0F,
|
||||
0x38, 0x44, 0x44, 0x38, 0x44,
|
||||
0xFC, 0x4A, 0x4A, 0x4A, 0x34, // sharp-s or beta
|
||||
0x7E, 0x02, 0x02, 0x06, 0x06,
|
||||
0x02, 0x7E, 0x02, 0x7E, 0x02,
|
||||
0x63, 0x55, 0x49, 0x41, 0x63,
|
||||
0x38, 0x44, 0x44, 0x3C, 0x04,
|
||||
0x40, 0x7E, 0x20, 0x1E, 0x20,
|
||||
0x06, 0x02, 0x7E, 0x02, 0x02,
|
||||
0x99, 0xA5, 0xE7, 0xA5, 0x99,
|
||||
0x1C, 0x2A, 0x49, 0x2A, 0x1C,
|
||||
0x4C, 0x72, 0x01, 0x72, 0x4C,
|
||||
0x30, 0x4A, 0x4D, 0x4D, 0x30,
|
||||
0x30, 0x48, 0x78, 0x48, 0x30,
|
||||
0xBC, 0x62, 0x5A, 0x46, 0x3D,
|
||||
0x3E, 0x49, 0x49, 0x49, 0x00,
|
||||
0x7E, 0x01, 0x01, 0x01, 0x7E,
|
||||
0x2A, 0x2A, 0x2A, 0x2A, 0x2A,
|
||||
0x44, 0x44, 0x5F, 0x44, 0x44,
|
||||
0x40, 0x51, 0x4A, 0x44, 0x40,
|
||||
0x40, 0x44, 0x4A, 0x51, 0x40,
|
||||
0x00, 0x00, 0xFF, 0x01, 0x03,
|
||||
0xE0, 0x80, 0xFF, 0x00, 0x00,
|
||||
0x08, 0x08, 0x6B, 0x6B, 0x08,
|
||||
0x36, 0x12, 0x36, 0x24, 0x36,
|
||||
0x06, 0x0F, 0x09, 0x0F, 0x06,
|
||||
0x00, 0x00, 0x18, 0x18, 0x00,
|
||||
0x00, 0x00, 0x10, 0x10, 0x00,
|
||||
0x30, 0x40, 0xFF, 0x01, 0x01,
|
||||
0x00, 0x1F, 0x01, 0x01, 0x1E,
|
||||
0x00, 0x19, 0x1D, 0x17, 0x12,
|
||||
0x00, 0x3C, 0x3C, 0x3C, 0x3C,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
#endif // FONT5X7_H
|
|
@ -1,26 +0,0 @@
|
|||
Software License Agreement (BSD License)
|
||||
|
||||
Copyright (c) 2012, Adafruit Industries
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
3. Neither the name of the copyright holders nor the
|
||||
names of its contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
Loading…
Reference in New Issue