Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
8x8 Pixel Art
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Stefan Schüller
8x8 Pixel Art
Commits
7d77e685
Commit
7d77e685
authored
5 years ago
by
Stefan Schueller
Browse files
Options
Downloads
Patches
Plain Diff
Updates
parent
af864d57
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
README.md
+1
-0
1 addition, 0 deletions
README.md
src/config.h
+13
-3
13 additions, 3 deletions
src/config.h
src/main.cpp
+61
-95
61 additions, 95 deletions
src/main.cpp
with
75 additions
and
98 deletions
README.md
+
1
−
0
View file @
7d77e685
...
...
@@ -13,6 +13,7 @@
### Required
-
ESP32 (LOLIN32)
-
8x8 LED matrix
-
Reset Button
### Optional
-
Light Sensor
...
...
This diff is collapsed.
Click to expand it.
src/config.h
+
13
−
3
View file @
7d77e685
...
...
@@ -7,16 +7,26 @@
// the digital pin for controlling the WS2812 LED Matrix
#define LED_PIN 3
#define DATA_PIN 3
#define COLOR_ORDER GRB
#define CHIPSET WS2811
#define BRIGHTNESS 16
// data directory (no trailing slash!)
#define GIF_DIRECTORY "/gifs"
#define GIF_UPLOAD_DIRECTORY "/gifs/"
// default brightness
#define BRIGHTNESS 16
// light sensor PIN, comment out of not connected
#define LIGHTSENSORPIN A0
// how long to display an animation
#define DISPLAY_TIME_SECONDS 10
// Wifi access point name
#define WIFIAPNAME "LEDMatrix"
// Time to wait (in seconds) for connection to portal
#define WIFIPORTALTIMEOUT 180
//
#define SET_BUTTON GPIO_NUM_15
#endif
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/main.cpp
+
61
−
95
View file @
7d77e685
...
...
@@ -12,7 +12,6 @@
#include
<EasyButton.h>
// Private Libs
#include
<GifDecoder.h>
#include
<FilenameFunctions.h>
...
...
@@ -27,13 +26,15 @@ boolean ready = false;
File
fileSave
;
DNSServer
dns
;
EasyButton
button
(
GPIO_NUM_15
);
EasyButton
button
(
SET_BUTTON
);
extern
StringArray
fileList
;
const
uint8_t
kMatrixWidth
=
MATRIX_WIDTH
;
const
uint8_t
kMatrixHeight
=
MATRIX_HEIGHT
;
const
String
upload_directory
=
String
(
GIF_DIRECTORY
)
+
"/"
;
#define NUMMATRIX (kMatrixWidth * kMatrixHeight)
CRGB
leds
[
NUMMATRIX
];
...
...
@@ -51,7 +52,7 @@ static void handle_update_progress_cb(AsyncWebServerRequest *request, String fil
if
(
!
index
)
{
Serial
.
println
(
"Begin upload"
);
fileSave
=
SPIFFS
.
open
(
GIF_UPLOAD_DIRECTORY
+
filename
,
FILE_WRITE
);
fileSave
=
SPIFFS
.
open
(
upload_directory
+
filename
,
FILE_WRITE
);
}
if
(
fileSave
.
write
(
data
,
len
)
!=
len
)
...
...
@@ -90,14 +91,14 @@ void matrix_clear()
void
display_scrollText
(
String
text
)
{
u
int
8
_t
textWidth
=
text
.
length
()
*
kMatrixWidth
;
int
16
_t
textWidth
=
text
.
length
()
*
kMatrixWidth
;
//uint8_t size = max(int(kMatrixWidth / 8), 1);
matrix_clear
();
matrix
->
setTextWrap
(
false
);
// we don't wrap text so it scrolls nicely
matrix
->
setTextSize
(
1
);
matrix
->
setRotation
(
0
);
for
(
int8_t
x
=
kMatrixWidth
;
x
>=
-
(
textWidth
);
x
--
)
for
(
int16_t
x
=
kMatrixWidth
;
x
>=
-
(
textWidth
);
x
--
)
{
yield
();
matrix_clear
();
...
...
@@ -107,10 +108,6 @@ void display_scrollText(String text)
matrix
->
show
();
delay
(
100
);
}
// matrix->setRotation(0);
// matrix->setCursor(0, 0);
// matrix->show();
}
String
imageElement
(
String
imagePath
,
int
imageId
)
...
...
@@ -179,22 +176,34 @@ String processor(const String &var)
return
String
();
}
void
on
Pressed
Callback
()
void
c
on
figMode
Callback
(
AsyncWiFiManager
*
wifiManager
)
{
Serial
.
println
(
"Button Press"
);
}
// void configModeCallback(AsyncWiFiManager *wifiManager)
// {
matrix
->
clear
();
Serial
.
println
(
"Entered config mode"
);
Serial
.
println
(
WiFi
.
softAPIP
());
// matrix->clear();
display_scrollText
(
String
(
"Connect to: "
+
wifiManager
->
getConfigPortalSSID
()));
display_scrollText
(
String
(
"Browse to: "
+
WiFi
.
softAPIP
()));
}
// Serial.println("Entered config mode");
// Serial.println(WiFi.softAPIP());
void
resetWifiConfig
()
{
Serial
.
println
(
"Wifi Settings reset"
);
wifiManager
.
resetSettings
();
WiFi
.
disconnect
(
false
,
true
);
WiFi
.
begin
(
"0"
,
"0"
);
WiFi
.
persistent
(
false
);
// Do not memorise new connections
//ESP.flashEraseSector(0x3fe);
Serial
.
println
(
"Rebooting in 10 seconds"
);
delay
(
10000
);
ESP
.
restart
();
}
// //display_scrollText(String("Connect to: " + wifiManager->getConfigPortalSSID()));
// //display_scrollText(String("Browse to: " + WiFi.softAPIP()));
// }
void
onPressedCallback
()
{
Serial
.
println
(
"Button Press"
);
resetWifiConfig
();
}
void
setupServer
()
{
...
...
@@ -208,16 +217,7 @@ void setupServer()
});
server
.
on
(
"/reset"
,
HTTP_GET
,
[](
AsyncWebServerRequest
*
request
)
{
Serial
.
println
(
"Wifi Settings reset"
);
wifiManager
.
resetSettings
();
WiFi
.
disconnect
(
false
,
true
);
WiFi
.
begin
(
"0"
,
"0"
);
WiFi
.
persistent
(
false
);
// Do not memorise new connections
//ESP.flashEraseSector(0x3fe);
Serial
.
println
(
"Rebooting in 10 seconds"
);
delay
(
10000
);
// wifiManager.autoConnect();
ESP
.
restart
();
resetWifiConfig
();
});
server
.
on
(
"/set"
,
HTTP_GET
,
[](
AsyncWebServerRequest
*
request
)
{
...
...
@@ -233,6 +233,14 @@ void setupServer()
}
});
server
.
on
(
"/ajax-brightness"
,
HTTP_GET
,
[](
AsyncWebServerRequest
*
request
)
{
return
String
(
light
);
request
->
send
(
200
,
contentType
,
content
);
});
server
.
on
(
"/delete"
,
HTTP_GET
,
[](
AsyncWebServerRequest
*
request
)
{
if
(
request
->
hasParam
(
"filename"
))
{
...
...
@@ -260,7 +268,6 @@ void setupServer()
server
.
serveStatic
(
"/"
,
SPIFFS
,
"/"
);
//.setDefaultFile("index.htm");
server
.
begin
();
}
void
setup
()
...
...
@@ -275,21 +282,6 @@ void setup()
Serial
.
begin
(
115200
);
//vTaskDelete(DrawLEDsHandle);
// WiFi.mode(WIFI_STA);
// WiFi.begin(ssid, password);
// if (WiFi.waitForConnectResult() != WL_CONNECTED)
// {
// Serial.printf("WiFi Failed!\n");
// return;
// }
// Serial.print("IP Address: ");
// Serial.println(WiFi.localIP());
// Serial.print("Hostname: ");
// Serial.println(WiFi.getHostname());
SPIFFS
.
begin
();
decoder
.
setScreenClearCallback
(
screenClearCallback
);
decoder
.
setUpdateScreenCallback
(
updateScreenCallback
);
...
...
@@ -302,12 +294,13 @@ void setup()
num_files
=
enumerateGIFFiles
(
GIF_DIRECTORY
,
false
);
#ifdef LIGHTSENSORPIN
pinMode
(
LIGHTSENSORPIN
,
INPUT
);
#endif
//wifiManager.setAPCallback(configModeCallback);
wifiManager
.
autoConnect
(
"LEDMatrix"
);
wifiManager
.
setConfigPortalTimeout
(
180
);
wifiManager
.
setAPCallback
(
configModeCallback
);
wifiManager
.
autoConnect
(
WIFIAPNAME
);
wifiManager
.
setConfigPortalTimeout
(
WIFIPORTALTIMEOUT
);
setupServer
();
}
...
...
@@ -320,8 +313,9 @@ void loop()
if
(
!
ready
)
{
ready
=
true
;
// String currentIp = WiFi.localIP().toString();
// display_scrollText(String("Browse to: ") + currentIp);
String
currentIp
=
WiFi
.
localIP
().
toString
();
display_scrollText
(
String
(
currentIp
));
display_scrollText
(
String
(
currentIp
));
}
else
{
...
...
@@ -342,50 +336,22 @@ void loop()
// Calculate time in the future to terminate animation
futureTime
=
millis
()
+
(
DISPLAY_TIME_SECONDS
*
1000
);
}
}
// auto brightness
int
light_value
=
analogRead
(
LIGHTSENSORPIN
);
light
=
light_value
*
0.062271
;
if
(
light
>
40
)
{
FastLED
.
setBrightness
(
light
);
}
else
{
FastLED
.
setBrightness
(
BRIGHTNESS
);
}
// auto brightness
#ifdef
LIGHTSENSORPIN
int
light_value
=
analogRead
(
LIGHTSENSORPIN
)
;
light
=
light_value
*
0.062271
;
if
(
light
>
40
)
{
FastLED
.
setBrightness
(
light
);
}
else
{
FastLED
.
setBrightness
(
BRIGHTNESS
);
}
#endif
decoder
.
decodeFrame
();
}
// else
// {
// if (!wifiManager.startConfigPortal("OnDemandAP")) {
// Serial.println("failed to connect and hit timeout");
// delay(3000);
// connect = false;
// //reset and try again, or maybe put it to deep sleep
// }
// //if you get here you have connected to the WiFi
// Serial.println("connected...yeey :)");
// if (WiFi.status() == WL_DISCONNECTED)
// {
// display_scrollText(String("Connect to: " + wifiManager.getConfigPortalSSID()));
// delay(1000);
// }
// else
// {
// if (serverRunning) {
// serverRunning = true;
// setupServer();
// }
// display_scrollText(String("Browse to: " + WiFi.localIP()));
// delay(1000);
// }
// }
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment