Skip to content

Commit b717240

Browse files
committed
first commit
0 parents  commit b717240

21 files changed

+3562
-0
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.pio
2+
.vscode/.browse.c_cpp.db*
3+
.vscode/c_cpp_properties.json
4+
.vscode/launch.json
5+
.vscode/ipch

.vscode/extensions.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
// See http://go.microsoft.com/fwlink/?LinkId=827846
3+
// for the documentation about the extensions.json format
4+
"recommendations": [
5+
"platformio.platformio-ide"
6+
],
7+
"unwantedRecommendations": [
8+
"ms-vscode.cpptools-extension-pack"
9+
]
10+
}

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"idf.adapterTargetName": "esp32"
3+
}

CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
cmake_minimum_required(VERSION 3.16.0)
2+
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
3+
project(oledi2s)

app3M_fat9M_16MB.csv

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Name, Type, SubType, Offset, Size, Flags
2+
nvs, data, nvs, 0x9000, 0x5000,
3+
otadata, data, ota, 0xe000, 0x2000,
4+
app0, app, ota_0, 0x10000, 0x300000,
5+
app1, app, ota_1, 0x310000,0x300000,
6+
ffat, data, fat, 0x610000,0x9E0000,
7+
coredump, data, coredump,0xFF0000,0x10000,
8+
# to create/use ffat, see https://github.com/marcmerlin/esp32_fatfsimage

include/app.hpp

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#pragma once
2+
3+
#include <Audio.h>
4+
#include <U8g2lib.h>
5+
#include <vector>
6+
#include <nvs_flash.h>
7+
#include "SD.h"
8+
#include "FS.h"
9+
#include <string>
10+
11+
#include "config.hpp"
12+
#include "file_.hpp"
13+
#include "encoder.hpp"
14+
#include "displayTools.hpp"
15+
16+
class App
17+
{
18+
public:
19+
App();
20+
void run();
21+
Audio* getAudio();
22+
23+
24+
private:
25+
void init();
26+
void initDisplay();
27+
void initAudio();
28+
void initSD();
29+
void initWifi();
30+
void selectMode();
31+
void mp3Player();
32+
void onlineRadio();
33+
void selectSong();
34+
void selectRadio();
35+
void createRadioList();
36+
void createDirList(std::string dir);
37+
38+
Audio audio;
39+
U8G2_SH1106_128X64_NONAME_F_HW_I2C display;
40+
Encoder encoder;
41+
DisplayTools displayTools;
42+
43+
std::vector<File_> radioList;
44+
std::vector<File_> fileList;
45+
int mode;
46+
int selectedSong;
47+
int selectedRadio;
48+
49+
};

include/config.hpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// I2S Connections
2+
#define I2S_DOUT 38
3+
#define I2S_BCLK 39
4+
#define I2S_LRC 20
5+
6+
// SD Connections
7+
#define SD_CS 13
8+
#define SPI_MOSI 40
9+
#define SPI_MISO 47
10+
#define SPI_SCK 15
11+
12+
// wifi connection
13+
#define WIFI true
14+
#define WIFI_SSID "ZTE-3XQ49P"
15+
#define WIFI_PASSWORD "bef2dn5ssb6n"
16+
17+
// rotary encoder
18+
#define CLK 45
19+
#define DT 4
20+
#define SW 2
21+
#define DIRECTION_CW 0 // clockwise direction
22+
#define DIRECTION_CCW 1 // counter-clockwise direction
23+
24+
// buttons
25+
#define BACK_SW 11
26+
27+
// font
28+
#define FONT_BIG u8g2_font_ncenR12_te
29+
#define FONT_SMALL u8g2_font_ncenR08_te

include/displayTools.hpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#pragma once
2+
3+
#include "file_.hpp"
4+
#include <vector>
5+
#include <U8g2lib.h>
6+
#include "config.hpp"
7+
#include <Audio.h>
8+
9+
class DisplayTools {
10+
public:
11+
void drawDisplayMenu(std::string title, std::vector<File_> list, int selected,U8G2_SH1106_128X64_NONAME_F_HW_I2C &display);
12+
void drawPlayerMenu(std::string title, std::vector<File_> list, int selected,U8G2_SH1106_128X64_NONAME_F_HW_I2C &display, Audio &audio);
13+
void init(U8G2_SH1106_128X64_NONAME_F_HW_I2C &display);
14+
};

include/encoder.hpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#pragma once
2+
#include "Arduino.h"
3+
4+
class Encoder{
5+
public:
6+
Encoder(int CLKPin, int DTPin);
7+
void selectOption (int &selectedOption, int maxPossibleNumberOfOptinos);
8+
9+
private:
10+
int CLKPin, DTPin;
11+
int prevCLKState;
12+
13+
};

include/file_.hpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#pragma once
2+
#include <string>
3+
4+
class File_{
5+
public:
6+
std::string path; //can acts as URL
7+
std::string name;
8+
bool isDirectory;
9+
};

include/main.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#include <Arduino.h>
2+
3+
#include "config.hpp"
4+
#include "app.hpp"

lib/README

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
2+
This directory is intended for project specific (private) libraries.
3+
PlatformIO will compile them to static libraries and link into executable file.
4+
5+
The source code of each library should be placed in an own separate directory
6+
("lib/your_library_name/[here are source files]").
7+
8+
For example, see a structure of the following two libraries `Foo` and `Bar`:
9+
10+
|--lib
11+
| |
12+
| |--Bar
13+
| | |--docs
14+
| | |--examples
15+
| | |--src
16+
| | |- Bar.c
17+
| | |- Bar.h
18+
| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html
19+
| |
20+
| |--Foo
21+
| | |- Foo.c
22+
| | |- Foo.h
23+
| |
24+
| |- README --> THIS FILE
25+
|
26+
|- platformio.ini
27+
|--src
28+
|- main.c
29+
30+
and a contents of `src/main.c`:
31+
```
32+
#include <Foo.h>
33+
#include <Bar.h>
34+
35+
int main (void)
36+
{
37+
...
38+
}
39+
40+
```
41+
42+
PlatformIO Library Dependency Finder will find automatically dependent
43+
libraries scanning project source files.
44+
45+
More information about PlatformIO Library Dependency Finder
46+
- https://docs.platformio.org/page/librarymanager/ldf.html

platformio.ini

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[env:esp32-s3-n16r8]
2+
board = esp32-s3-n16r8
3+
framework = arduino, espidf
4+
platform = espressif32
5+
6+
lib_deps =
7+
olikraus/U8g2@^2.35.15
8+
esphome/ESP32-audioI2S@^2.0.7
9+
10+
monitor_speed = 115200
11+
upload_speed = 4000000
12+
13+
board_build.partitions = app3M_fat9M_16MB.csv
14+
15+
build_flags =
16+
-DCORE_DEBUG_LEVEL=5
17+
18+

0 commit comments

Comments
 (0)