-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 30459a2
Showing
5 changed files
with
173 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#include "Libofanten.h" | ||
|
||
#define PANELS 3 | ||
|
||
uint8_t offset_value = 0; | ||
|
||
void setup() { | ||
Blof.begin(PANELS); | ||
} | ||
|
||
void sinus(int wellenlaenge, int offset) { | ||
for (int i=0; i<PANELS*8; i++) { | ||
float factor=2*PI/wellenlaenge; | ||
int x = round(sin((i-offset)*factor)*4)+4; | ||
Blof.setPixel(i, x, 1); | ||
} | ||
} | ||
|
||
void loop() { | ||
Blof.clear(); | ||
sinus(24,offset_value); | ||
offset_value = (offset_value + 1) % 24; | ||
Blof.flush(); | ||
delay(30); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
####################################### | ||
# Datatypes (KEYWORD1) | ||
####################################### | ||
|
||
Blof KEYWORD1 | ||
|
||
####################################### | ||
# Methods and Functions (KEYWORD2) | ||
####################################### | ||
|
||
begin KEYWORD2 | ||
clear KEYWORD2 | ||
setBlink KEYWORD2 | ||
setPixel KEYWORD2 | ||
off KEYWORD2 | ||
on KEYWORD2 | ||
flush KEYWORD2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
name=Libofanten | ||
version=1.0 | ||
author=DevLol | ||
maintainer=jstsmthrgk | ||
sentence=Library for Blinkofanten LED Matrix. | ||
paragraph=This is a library to use the Blinkofanten LED Matrix. | ||
url=https://github.com/devlol/Libofanten | ||
category=Display |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/* | ||
Libofanten.h - Library for using Blinkofanten LED Matrix | ||
Created by jstsmthrgk | ||
basically a library wrapper of blinkofant_testcode.ino by wizard23 and TomK32 | ||
https://github.com/DevLoL/blinkofanten/blob/master/blinkofant_testcode/blinkofant_testcode.ino | ||
*/ | ||
|
||
|
||
#include "Libofanten.h" | ||
#include "SPI.h" | ||
|
||
BlofClass Blof; | ||
int BlofClass::active = 1; | ||
int BlofClass::panels; | ||
int BlofClass::panelDataSize; | ||
uint8_t * BlofClass::panelData; | ||
|
||
void BlofClass::begin(int panelcount) { | ||
panels = panelcount; | ||
panelDataSize = panels*10; | ||
panelData = new uint8_t[panelDataSize]; | ||
|
||
pinMode(CLEAR_PANEL_PIN, OUTPUT); | ||
pinMode(DATA_PIN, OUTPUT); | ||
pinMode(CLOCK_PIN, OUTPUT); | ||
|
||
digitalWrite(CLEAR_PANEL_PIN, LOW); | ||
digitalWrite(DATA_PIN, LOW); | ||
digitalWrite(CLOCK_PIN, LOW); | ||
|
||
SPI.begin(); | ||
SPI.setBitOrder(LSBFIRST); | ||
SPI.setDataMode(SPI_MODE0); | ||
SPI.setClockDivider(SPI_CLOCK_DIV128); // biggest divider there is. | ||
} | ||
|
||
void BlofClass::clear() { | ||
for (int i = 0; i < panelDataSize; i++) { | ||
panelData[i] = 0; | ||
} | ||
} | ||
|
||
void BlofClass::setBlink(int col, int val) { | ||
setPixel(col, -1, val); | ||
} | ||
|
||
void BlofClass::setPixel(int col, int row, int val) { | ||
int index = (row + 1) + col * 10; // y+1 because 1st bit controlls blinking | ||
int byteNr = index >> 3; // division by 8 | ||
int bitNr = index & 0x7; // rest bei div durch 8 | ||
|
||
if (val) | ||
{ | ||
panelData[byteNr] |= 1 << bitNr; | ||
} else { | ||
panelData[byteNr] &= ~(1 << bitNr); | ||
} | ||
} | ||
|
||
void BlofClass::off() { | ||
active = 0; | ||
digitalWrite(CLEAR_PANEL_PIN, LOW); | ||
} | ||
|
||
void BlofClass::on() { | ||
active = 1; | ||
digitalWrite(CLEAR_PANEL_PIN, HIGH); | ||
} | ||
|
||
void BlofClass::flush() { | ||
if (active) { | ||
digitalWrite(CLEAR_PANEL_PIN, LOW); | ||
} | ||
for (int i = 0; i < panelDataSize; i++) { | ||
uint8_t value = panelData[i]; | ||
SPDR = panelData[i]; | ||
while (!(SPSR & (1 << SPIF))); | ||
} | ||
if (active) { | ||
digitalWrite(CLEAR_PANEL_PIN, HIGH); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
Libofanten.h - Library for using Blinkofanten LED Matrix | ||
Created by jstsmthrgk | ||
basically a library wrapper of blinkofant_testcode.ino by wizard23 and TomK32 | ||
https://github.com/DevLoL/blinkofanten/blob/master/blinkofant_testcode/blinkofant_testcode.ino | ||
*/ | ||
|
||
#ifndef LIBOFANTEN_H | ||
#define LIBOFANTEN_H | ||
|
||
#include "Arduino.h" | ||
|
||
#ifdef ESP8266_WEMOS_D1MINI | ||
#define CLEAR_PANEL_PIN D8 // pin #10 on the blinkofant panel | ||
#define DATA_PIN D7 // pin #8 | ||
#define CLOCK_PIN D5 // pin #4 | ||
#else | ||
#define CLEAR_PANEL_PIN 10 // this goes on panel to pin #10 on the blinkofant panel | ||
#define DATA_PIN 11 // pin #8 | ||
#define CLOCK_PIN 13 // pin #4 | ||
#endif | ||
|
||
class BlofClass { | ||
public: | ||
static void begin(int panelcount); | ||
static void clear(); | ||
static void setBlink(int col, int val); | ||
static void setPixel(int col, int row, int val); | ||
static void off(); | ||
static void on(); | ||
static void flush(); | ||
private: | ||
static int panels; | ||
static int panelDataSize; | ||
static uint8_t * panelData; | ||
static int active; | ||
}; | ||
|
||
extern BlofClass Blof; | ||
|
||
#endif |