Skip to content

Instantly share code, notes, and snippets.

View CelliesProjects's full-sized avatar
🖥️
Busy coding...

Cellie CelliesProjects

🖥️
Busy coding...
View GitHub Profile
@CelliesProjects
CelliesProjects / SetClockOnPin.ino
Created December 4, 2019 20:12
ESP32 - Example setting a clock signal (50% duty cycle) on a pin.
#include "driver/ledc.h"
static void enable_out_clock(uint8_t pin,double freq) {
periph_module_enable(PERIPH_LEDC_MODULE);
ledc_timer_bit_t bit_num = (ledc_timer_bit_t) 1; // 3 normally
int duty = pow(2, (int) bit_num) / 2;
ledc_timer_config_t timer_conf;
timer_conf.bit_num = bit_num;
timer_conf.freq_hz = freq;
@CelliesProjects
CelliesProjects / M5BalaMotorCode.ino
Created November 28, 2019 17:42
POC to drive M5 Balancer Robot I2C base with motors.
#include <Wire.h>
#define M5GO_WHEEL_ADDR 0x56
#define MOTOR_CTRL_ADDR 0x00
#define ENCODER_ADDR 0x04
#define DEAD_ZONE 5
void setMotor(int16_t pwm0, int16_t pwm1) {
Wire.beginTransmission(M5GO_WHEEL_ADDR);
Wire.write(MOTOR_CTRL_ADDR); // Motor ctrl reg addr
@CelliesProjects
CelliesProjects / detect_WM8978.ino
Created November 22, 2019 22:19
Simple poc to show how to detect a i2c wm8978 codec in esp32 arduino.
#include <Wire.h>
void setup() {
// put your setup code here, to run once:
Wire.begin( 21, 22, 400000 );
Wire.beginTransmission( 0X1A );
uint8_t error = Wire.endTransmission();
if ( error ) ESP_LOGI( TAG, "No codec found." );
}
@CelliesProjects
CelliesProjects / m5Stack-ESP32-StreamMP3FromHTTP.ino
Created November 22, 2019 20:50
POC streaming for M5Stack ESP32 boards
#include <Arduino.h>
#ifdef ESP32
#include <WiFi.h>
#else
#include <ESP8266WiFi.h>
#endif
#include "AudioFileSourceICYStream.h"
#include "AudioFileSourceBuffer.h"
#include "AudioGeneratorMP3a.h"
@CelliesProjects
CelliesProjects / MP3_allocatedBuffer.ino
Last active November 25, 2019 19:46
M5Stack Fire - POC to show how to decode mp3 with allocated buffers on esp32.
//AudioOutPutI2S.cpp is aangepast
//Works on a M5Stack Fire with PSRAM enabled - compiled for esp32 dev kit - 16MB flash - 4MB PSRAM
#include <WiFi.h>
//#include <TFT_eSPI.h>
#include "AudioFileSourceICYStream.h"
#include "AudioFileSourceBuffer.h"
#include "AudioGeneratorMP3a.h"
#include "AudioOutputI2S.h"
#define BUTTON_A 39
@CelliesProjects
CelliesProjects / M5_PlayMP3FromHTTPToDAC.ino
Created November 20, 2019 13:48
M5Stack Fire - Play a web stream on internal DAC.
#pragma mark - Depend ESP8266Audio and ESP8266_Spiram libraries
/*
cd ~/Arduino/libraries
git clone https://github.com/earlephilhower/ESP8266Audio
git clone https://github.com/Gianbacchio/ESP8266_Spiram
Use the "Tools->ESP32 Sketch Data Upload" menu to write the MP3 to SPIFFS
Then upload the sketch normally.
https://github.com/me-no-dev/arduino-esp32fs-plugin
*/
@CelliesProjects
CelliesProjects / DualMPU9250Basic.ino
Created November 19, 2019 15:12 — forked from botamochi6277/DualMPU9250Basic.ino
Dual MPU9250 libraries for M5stack
/**
* MPU9250 Basic Example Code for Dual MPU9250
* Copyright (c) 2014 Kris Winer
* Copyright (c) 2018 botamochi6277
* license: Beerware - Use this code however you'd like. If you
* find it useful you can buy me a beer some time.
*/
#include <M5Stack.h>
#include "utility/MPU9250.h"
@CelliesProjects
CelliesProjects / Free_fonts.h
Created November 11, 2019 18:56
Analogue clock for M5Stack. Uses 'TFT_eSPI.h' and 'TFTShape.h' Arduino IDE.
// Attach this header file to your sketch to use the GFX Free Fonts. You can write
// sketches without it, but it makes referencing them easier.
// This calls up ALL the fonts but they only get loaded if you actually
// use them in your sketch.
//
// No changes are needed to this header file unless new fonts are added to the
// library "Fonts/GFXFF" folder.
//
// To save a lot of typing long names, each font can easily be referenced in the
@CelliesProjects
CelliesProjects / voiceRecorder.ino
Last active March 13, 2021 19:12
POC voice recorder for M5Stack Fire with a M5 Go Base. Compiles in the Arduino IDE.
// https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/peripherals/adc.html
/* this example has to be compiled with PSRAM enabled. */
#include <M5Stack.h>
#include <driver/adc.h>
#define MICROPHONE 34
#define SPEAKER 25
#define BACKLIGHT 32
#define BUFFER_SIZE 1000*1000
@CelliesProjects
CelliesProjects / visualisation_2core.ino
Created November 1, 2019 14:06
Music visualisation on a M5Stack Fire. Arduino IDE.
#include "arduinoFFT.h"
//#include <M5Stack.h>
//#include <esp_wifi.h>
#include <TFT_eSPI.h>
//#include <M5Display.h> // This library is a lot faster! But also a lot larger.
#define microphone 34
#define speaker 25
#define backlight 32