aboutsummaryrefslogtreecommitdiff
path: root/Arduino/Libraies/AS1107/AS1107.h
diff options
context:
space:
mode:
Diffstat (limited to 'Arduino/Libraies/AS1107/AS1107.h')
-rwxr-xr-xArduino/Libraies/AS1107/AS1107.h147
1 files changed, 147 insertions, 0 deletions
diff --git a/Arduino/Libraies/AS1107/AS1107.h b/Arduino/Libraies/AS1107/AS1107.h
new file mode 100755
index 0000000..60ad6ad
--- /dev/null
+++ b/Arduino/Libraies/AS1107/AS1107.h
@@ -0,0 +1,147 @@
+/*
+ AS1107.h - Library for interfacing the AS1107 LED Driver Chip
+ Created by Stephan Elsner 2011
+ version 0.82
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+*/
+
+#ifndef AS1107_h
+#define AS1107_h
+
+#include "WProgram.h"
+#include <avr/pgmspace.h>
+
+#define ON 1
+#define OFF 0
+
+
+// --------------------------------------------------------------------------------------------------------------------------
+class AS1107
+{
+ public:
+ AS1107(byte cspin, byte clkpin, byte datapin);
+ void WriteRegister2(byte chip, byte reg, byte data);
+ void WriteRegister(byte chip, byte reg, byte data);
+ void WriteColumn( byte column, byte data);
+ void Init(byte *buffer);
+ void SetBuffer(byte *buffer);
+ void SetLed(int x, int y, byte value);
+ void Clear();
+ void Update();
+ void ShiftLeft();
+ void ShiftRight();
+ void ShiftUp();
+ void ShiftDown();
+ void ShiftUp(byte from, byte to);
+ void ShiftDown(byte from, byte to);
+ void DrawLine(int x0, int y0, int x1, int y1);
+ void DrawBox(int x0, int y0, int x1, int y1);
+ void DrawEllipse(int xm, int ym, int a, int b);
+ void SetScrollText(char *string, int charspacing);
+ void DrawText (int x, int y, char *str);
+ byte DrawChar (int x, int y, char thechar);
+
+ boolean TextScroll();
+
+ // ***************************************
+ // Set your module configuration here
+ // ***************************************
+ static const byte Maxx=15; // maximum x - Pixels of the Module
+ static const byte Maxy=7; // maximum y - Pixels of the Module
+ static const byte HighestCtrlNum=1; // Number of Matrix modules -1 (0 = single module)
+
+ private:
+ byte _cspin;
+ byte _clkpin;
+ byte _datapin;
+ byte *_buffer; // pointer to current screen buffer
+
+ static const byte _repcharoff; // Offset of the replacement for unknown characers
+ int _charoffset[82]; // Start position in Array
+ char *_outputstring; // pointer to start of output string
+ char *_curchr; // pointer to current char of output String
+ int _fontidx; // current byte in font to display
+ int _colct; // to count the columns of character to display
+ byte _charspacing; // the coulumns of space between characters
+ boolean _hastext;
+
+ void SetLedInternal(byte x, byte y, byte value);
+ boolean NextCharacter();
+ void CalculateCharOffsets();
+ byte GetInternalCharCode(byte thechar);
+};
+
+// --------------------------------------------------------------------------------------------------------------------------
+// AS1107-Register
+class Registers
+{
+ public:
+ static const byte NoOp = 0x00;
+ static const byte Digit0 = 0x01;
+ static const byte Digit1 = 0x02;
+ static const byte Digit2 = 0x03;
+ static const byte Digit3 = 0x04;
+ static const byte Digit4 = 0x05;
+ static const byte Digit5 = 0x06;
+ static const byte Digit6 = 0x07;
+ static const byte Digit7 = 0x08;
+ static const byte DecodeMode = 0x09;
+ static const byte IntensityControl = 0x0A;
+ static const byte ScanLimit = 0x0B;
+ static const byte Shutdown = 0x0C;
+ static const byte Feature = 0x0E;
+ static const byte DisplayTest = 0x0F;
+};
+
+// --------------------------------------------------------------------------------------------------------------------------
+// Values to write to the Shutdown Register
+class ShutdownModes
+{
+ public:
+ static const byte ShutdownResetFeature = 0x00; // Shutdown Mode, Reset Feature Register to Default Settings
+ static const byte Shutdown = 0x80; // Shutdown Mode, leaving Feature Register unchanged
+ static const byte NormalResetFeature = 0x01; // Normal Mode, Reset Feature
+ static const byte Normal = 0x81; // Normal Mode, Feature unchanged
+};
+
+// Bits in the feature-Register, desired Settings must be OR'ed together
+class Features
+{
+ public:
+ static const byte ExternalClock = 0x01; // ExternalClock active
+ static const byte ResetRegisters = 0x02; // Resets all control registers except the Feature Register.
+ static const byte HexDecoding = 0x04; // 1 = Enable HEX decoding, 0 = Enable Code-B decoding
+ static const byte SPIEnable = 0x08; // Enables the SPI-compatible interface.(AS1106 only).
+ static const byte BlinkEnable = 0x10; // Enables blinking.
+ static const byte BlinkSlow = 0x20; // Sets blink with low frequency
+ // (with the internal oscillator enabled)
+
+ static const byte BlinkSync = 0x40; // Synchronizes blinking on the rising edge of pin LOAD/CSN.
+ // The multiplex and blink timing counter is cleared on the
+ // rising edge of pin LOAD/CSN. By setting this bit in
+ // multiple AS1106/AS1107 devices, the blink timing can
+ // be synchronized across all the devices.
+
+ static const byte BlinkStartWithOn = 0x80; // Start Blinking with display enabled phase.
+ // When bit D4 (blink_en) is set, bit D7
+ // determines how blinking starts.
+ // 0 = Blinking starts with the display turned off.
+ // 1 = Blinking starts with the display turned on.
+};
+
+#endif
+
+ \ No newline at end of file