Skip to content

Commit

Permalink
New branch, matrix display for TTS messages
Browse files Browse the repository at this point in the history
Pull request, based on issue filed by @dosipod schmurtzm#21 and their work at https://github.com/MoonModules/WLED-Projects/tree/master/MadLab%40Aldiy 
I would suggest this is not merged into main project as it is for a specific matrix display panel, but perhaps left as a separate branch.  Nice concept.  (I haven't tested as I do not have a suitable matrix display).
  • Loading branch information
markvader authored Jul 27, 2022
1 parent af1fdd6 commit b60e11f
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,18 @@ ______ _____ _____ ___ ___ __ __
#include "AudioGeneratorAAC.h"
#include <AudioGeneratorFLAC.h>

//=====Matrix-display-imports-16x8 panel=====
#include <Adafruit_GFX.h>
#include <TM1640.h>
#include <TM16xxMatrixGFX.h>
TM1640 module(21,19) ;
// TM1640 module(21,22) ; to avoid conflict with GPIO 22
//TM1640 module(5,18);
#define MATRIX_NUMCOLUMNS 16
#define MATRIX_NUMROWS 8
TM16xxMatrixGFX matrix(&module, MATRIX_NUMCOLUMNS, MATRIX_NUMROWS);
//============================================

// #ifdef USE_NO_DAC
#include "AudioOutputI2SNoDAC.h"
// #else
Expand Down Expand Up @@ -738,10 +750,16 @@ void onMqttMessage(char *topic, byte *payload, unsigned int mlength)
{
sam->Say(out, newMsg);
Serial.print(soundOutputValue);
//===========display after talk ===========
scrollMessage(newMsg ,80);
//===========================================

}else{
sam->Say(outNoDac, newMsg);
Serial.print(soundOutputValue);
//===========display after talk ===========
scrollMessage(newMsg ,80);
//===========================================
}


Expand Down Expand Up @@ -1046,6 +1064,12 @@ void configSaved()
void setup()
{

//// ******************* setup matrix *************************************//
matrix.setRotation(3);
matrix.setMirror(false, true);
matrix.setTextWrap(false);
//// ******************* setup matrix end*********************************//

#ifdef DEBUG_FLAG
Serial.begin(115200);
#endif
Expand Down Expand Up @@ -1158,6 +1182,12 @@ void loop()
if (iotWebConf.getState() == iotwebconf::OnLine){
mqttReconnect();
mqttClient.loop();

//===========================================
// String fin_Message;
// fin_Message="yes working blue 8x16";
// scrollMessage(fin_Message,80);
//===========================================
}
if (!mp3)
iotWebConf.doLoop(); // give processor priority to web server
Expand Down Expand Up @@ -1225,3 +1255,20 @@ if (ButtonsDatas[0].CurrentButtonstate == 1 || ButtonsDatas[0].CurrentButtonstat
if (ButtonsDatas[1].CurrentButtonstate == 1 || ButtonsDatas[1].CurrentButtonstate == 8) SetVolume("+",false);

}

/**********************Matrix scrolling end *******************************/

void scrollMessage(String mx_message, int rate) {

int cursor_pos = 16;
for(int i = 0; i < 22 + (mx_message.length()+1) * 5; i++) {
matrix.fillScreen(0);
matrix.setCursor(cursor_pos,0);
matrix.print((String)mx_message);
matrix.write();
cursor_pos -= 1;
delay(rate);
}
}

/**********************Matrix scrolling end *******************************/

0 comments on commit b60e11f

Please sign in to comment.