rename folders
This commit is contained in:
parent
1ec8effe90
commit
1815597374
63 changed files with 1 additions and 0 deletions
18
ESPMegaPRO-firmware/src/.vscode/c_cpp_properties.json
vendored
Normal file
18
ESPMegaPRO-firmware/src/.vscode/c_cpp_properties.json
vendored
Normal file
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
"configurations": [
|
||||
{
|
||||
"name": "windows-gcc-x64",
|
||||
"includePath": [
|
||||
"${workspaceFolder}/**"
|
||||
],
|
||||
"compilerPath": "gcc",
|
||||
"cStandard": "${default}",
|
||||
"cppStandard": "${default}",
|
||||
"intelliSenseMode": "windows-gcc-x64",
|
||||
"compilerArgs": [
|
||||
""
|
||||
]
|
||||
}
|
||||
],
|
||||
"version": 4
|
||||
}
|
24
ESPMegaPRO-firmware/src/.vscode/launch.json
vendored
Normal file
24
ESPMegaPRO-firmware/src/.vscode/launch.json
vendored
Normal file
|
@ -0,0 +1,24 @@
|
|||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "C/C++ Runner: Debug Session",
|
||||
"type": "cppdbg",
|
||||
"request": "launch",
|
||||
"args": [],
|
||||
"stopAtEntry": false,
|
||||
"externalConsole": true,
|
||||
"cwd": "d:/Git/ESPMegaPRO-v3-SDK/Template Project/src",
|
||||
"program": "d:/Git/ESPMegaPRO-v3-SDK/Template Project/src/build/Debug/outDebug",
|
||||
"MIMode": "gdb",
|
||||
"miDebuggerPath": "gdb",
|
||||
"setupCommands": [
|
||||
{
|
||||
"description": "Enable pretty-printing for gdb",
|
||||
"text": "-enable-pretty-printing",
|
||||
"ignoreFailures": true
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
58
ESPMegaPRO-firmware/src/.vscode/settings.json
vendored
Normal file
58
ESPMegaPRO-firmware/src/.vscode/settings.json
vendored
Normal file
|
@ -0,0 +1,58 @@
|
|||
{
|
||||
"C_Cpp_Runner.cCompilerPath": "gcc",
|
||||
"C_Cpp_Runner.cppCompilerPath": "g++",
|
||||
"C_Cpp_Runner.debuggerPath": "gdb",
|
||||
"C_Cpp_Runner.cStandard": "",
|
||||
"C_Cpp_Runner.cppStandard": "",
|
||||
"C_Cpp_Runner.msvcBatchPath": "",
|
||||
"C_Cpp_Runner.useMsvc": false,
|
||||
"C_Cpp_Runner.warnings": [
|
||||
"-Wall",
|
||||
"-Wextra",
|
||||
"-Wpedantic",
|
||||
"-Wshadow",
|
||||
"-Wformat=2",
|
||||
"-Wcast-align",
|
||||
"-Wconversion",
|
||||
"-Wsign-conversion",
|
||||
"-Wnull-dereference"
|
||||
],
|
||||
"C_Cpp_Runner.msvcWarnings": [
|
||||
"/W4",
|
||||
"/permissive-",
|
||||
"/w14242",
|
||||
"/w14287",
|
||||
"/w14296",
|
||||
"/w14311",
|
||||
"/w14826",
|
||||
"/w44062",
|
||||
"/w44242",
|
||||
"/w14905",
|
||||
"/w14906",
|
||||
"/w14263",
|
||||
"/w44265",
|
||||
"/w14928"
|
||||
],
|
||||
"C_Cpp_Runner.enableWarnings": true,
|
||||
"C_Cpp_Runner.warningsAsError": false,
|
||||
"C_Cpp_Runner.compilerArgs": [],
|
||||
"C_Cpp_Runner.linkerArgs": [],
|
||||
"C_Cpp_Runner.includePaths": [],
|
||||
"C_Cpp_Runner.includeSearch": [
|
||||
"*",
|
||||
"**/*"
|
||||
],
|
||||
"C_Cpp_Runner.excludeSearch": [
|
||||
"**/build",
|
||||
"**/build/**",
|
||||
"**/.*",
|
||||
"**/.*/**",
|
||||
"**/.vscode",
|
||||
"**/.vscode/**"
|
||||
],
|
||||
"C_Cpp_Runner.useAddressSanitizer": false,
|
||||
"C_Cpp_Runner.useUndefinedSanitizer": false,
|
||||
"C_Cpp_Runner.useLeakSanitizer": false,
|
||||
"C_Cpp_Runner.showCompilationTime": false,
|
||||
"C_Cpp_Runner.useLinkTimeOptimization": false
|
||||
}
|
22
ESPMegaPRO-firmware/src/analogdemo.cpp.disabled
Normal file
22
ESPMegaPRO-firmware/src/analogdemo.cpp.disabled
Normal file
|
@ -0,0 +1,22 @@
|
|||
#include <ESPMegaPRO.h>
|
||||
#define ADC
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
ESPMega_begin();
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
#ifdef DAC
|
||||
for(int i=0;i<4096;i++) {
|
||||
ESPMega_dacWrite(0,i);
|
||||
double dac_val_sine = 2047.5*sin(i*2*PI/2047.5)+2047.5;
|
||||
ESPMega_dacWrite(1,(int)dac_val_sine);
|
||||
}
|
||||
#endif
|
||||
#ifdef ADC
|
||||
Serial.printf("A0: %d",ESPMega_analogRead(0));
|
||||
#endif
|
||||
}
|
76
ESPMegaPRO-firmware/src/cardsdemo.cpp.disabled
Normal file
76
ESPMegaPRO-firmware/src/cardsdemo.cpp.disabled
Normal file
|
@ -0,0 +1,76 @@
|
|||
#include <ESPMegaPRO_OOP.hpp>
|
||||
#include <DigitalInputCard.hpp>
|
||||
#include <DigitalOutputCard.hpp>
|
||||
#include <AnalogCard.hpp>
|
||||
|
||||
// This code demonstrates how to use the cards
|
||||
|
||||
ESPMegaPRO espmega = ESPMegaPRO();
|
||||
AnalogCard analogCard = AnalogCard();
|
||||
|
||||
void inputCallback(uint8_t pin, bool state)
|
||||
{
|
||||
Serial.print("Input ");
|
||||
Serial.print(pin);
|
||||
Serial.print(" changed to ");
|
||||
Serial.println(state);
|
||||
}
|
||||
|
||||
void printInputs()
|
||||
{
|
||||
for (int i = 0; i < 16; i++)
|
||||
{
|
||||
Serial.print("Input ");
|
||||
Serial.print(i);
|
||||
Serial.print(": ");
|
||||
Serial.print(espmega.inputs.digitalRead(i));
|
||||
Serial.println();
|
||||
}
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
// Instantiate ESPMega
|
||||
espmega.begin();
|
||||
Serial.println("ESPMega initialized");
|
||||
// Read all the inputs and print them
|
||||
printInputs();
|
||||
// Turn on all the outputs
|
||||
for (int i = 0; i < 16; i++)
|
||||
{
|
||||
espmega.outputs.digitalWrite(i, true);
|
||||
}
|
||||
// Set the debounce time for all inputs to 200ms
|
||||
for (int i = 0; i < 16; i++)
|
||||
{
|
||||
espmega.inputs.setDebounceTime(i, 200);
|
||||
}
|
||||
// Register the callback function
|
||||
espmega.inputs.registerCallback(inputCallback);
|
||||
|
||||
// Install the analog card
|
||||
Serial.println("Installing analog card");
|
||||
if (espmega.installCard(0, &analogCard))
|
||||
{
|
||||
Serial.println("Analog card installed");
|
||||
}
|
||||
else
|
||||
{
|
||||
Serial.println("Failed to install analog card");
|
||||
}
|
||||
}
|
||||
|
||||
unsigned long previousMillis = 0;
|
||||
const unsigned long interval = 1000; // 1 second
|
||||
|
||||
void loop()
|
||||
{
|
||||
unsigned long currentMillis = millis();
|
||||
|
||||
if (currentMillis - previousMillis >= interval)
|
||||
{
|
||||
previousMillis = currentMillis;
|
||||
printInputs();
|
||||
}
|
||||
espmega.loop();
|
||||
}
|
37
ESPMegaPRO-firmware/src/fram_demo.cpp.disabled
Normal file
37
ESPMegaPRO-firmware/src/fram_demo.cpp.disabled
Normal file
|
@ -0,0 +1,37 @@
|
|||
#include <ESPMegaPRO.h>
|
||||
void setup()
|
||||
{
|
||||
ESPMega_begin();
|
||||
Serial.begin(115200);
|
||||
uint8_t a = 35;
|
||||
uint8_t b = 42;
|
||||
uint8_t c = 66;
|
||||
uint8_t d = 251;
|
||||
|
||||
// ESPMega_FRAM.write8(0,a);
|
||||
// ESPMega_FRAM.write8(1,b);
|
||||
// ESPMega_FRAM.write8(2,c);
|
||||
// ESPMega_FRAM.write8(3,d);
|
||||
|
||||
uint8_t e = ESPMega_FRAM.read8(0);
|
||||
uint8_t f = ESPMega_FRAM.read8(1);
|
||||
uint8_t g = ESPMega_FRAM.read8(2);
|
||||
uint8_t h = ESPMega_FRAM.read8(3);
|
||||
Serial.println(e);
|
||||
Serial.println(f);
|
||||
Serial.println(g);
|
||||
Serial.println(h);
|
||||
char ll[2000] = "Everyone has a dream they strive to achieve, and so does the musically talented Kanon Shibuya. However, due to her stage fright, Kanon fails to make it into Yuigaoka Girls' High School's music program and instead ends up in the general curriculum. Even though Kanon makes the conscious decision to quit music altogether, her classmate Tang Keke rekindles Kanon's passion for music with her own: a passion for school idols.";
|
||||
|
||||
// ESPMega_FRAM.write(4,(uint8_t*)ll,2000);
|
||||
|
||||
char llr[2000];
|
||||
ESPMega_FRAM.read(4,(uint8_t*)llr,2000);
|
||||
Serial.println(llr);
|
||||
|
||||
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
}
|
84
ESPMegaPRO-firmware/src/i2c_scanner.cpp.disabled
Normal file
84
ESPMegaPRO-firmware/src/i2c_scanner.cpp.disabled
Normal file
|
@ -0,0 +1,84 @@
|
|||
#include <ESPMegaPRO.h>
|
||||
// --------------------------------------
|
||||
// i2c_scanner
|
||||
//
|
||||
// Version 1
|
||||
// This program (or code that looks like it)
|
||||
// can be found in many places.
|
||||
// For example on the Arduino.cc forum.
|
||||
// The original author is not know.
|
||||
// Version 2, Juni 2012, Using Arduino 1.0.1
|
||||
// Adapted to be as simple as possible by Arduino.cc user Krodal
|
||||
// Version 3, Feb 26 2013
|
||||
// V3 by louarnold
|
||||
// Version 4, March 3, 2013, Using Arduino 1.0.3
|
||||
// by Arduino.cc user Krodal.
|
||||
// Changes by louarnold removed.
|
||||
// Scanning addresses changed from 0...127 to 1...119,
|
||||
// according to the i2c scanner by Nick Gammon
|
||||
// https://www.gammon.com.au/forum/?id=10896
|
||||
// Version 5, March 28, 2013
|
||||
// As version 4, but address scans now to 127.
|
||||
// A sensor seems to use address 120.
|
||||
// Version 6, November 27, 2015.
|
||||
// Added waiting for the Leonardo serial communication.
|
||||
//
|
||||
//
|
||||
// This sketch tests the standard 7-bit addresses
|
||||
// Devices with higher bit address might not be seen properly.
|
||||
//
|
||||
|
||||
#include <Wire.h>
|
||||
|
||||
|
||||
void setup()
|
||||
{
|
||||
Wire.setClock(50000);
|
||||
Wire.begin(14,33);
|
||||
|
||||
Serial.begin(115200); // Leonardo: wait for serial monitor
|
||||
Serial.println("\nI2C Scanner");
|
||||
}
|
||||
|
||||
|
||||
void loop()
|
||||
{
|
||||
byte error, address;
|
||||
int nDevices;
|
||||
|
||||
Serial.println("Scanning...");
|
||||
|
||||
nDevices = 0;
|
||||
for(address = 1; address < 127; address++ )
|
||||
{
|
||||
// The i2c_scanner uses the return value of
|
||||
// the Write.endTransmisstion to see if
|
||||
// a device did acknowledge to the address.
|
||||
Wire.beginTransmission(address);
|
||||
error = Wire.endTransmission();
|
||||
|
||||
if (error == 0)
|
||||
{
|
||||
Serial.print("I2C device found at address 0x");
|
||||
if (address<16)
|
||||
Serial.print("0");
|
||||
Serial.print(address,HEX);
|
||||
Serial.println(" !");
|
||||
|
||||
nDevices++;
|
||||
}
|
||||
else if (error==4)
|
||||
{
|
||||
Serial.print("Unknown error at address 0x");
|
||||
if (address<16)
|
||||
Serial.print("0");
|
||||
Serial.println(address,HEX);
|
||||
}
|
||||
}
|
||||
if (nDevices == 0)
|
||||
Serial.println("No I2C devices found\n");
|
||||
else
|
||||
Serial.println("done\n");
|
||||
|
||||
delay(5000); // wait 5 seconds for next scan
|
||||
}
|
505
ESPMegaPRO-firmware/src/i2cmssc.cpp.disabled
Normal file
505
ESPMegaPRO-firmware/src/i2cmssc.cpp.disabled
Normal file
|
@ -0,0 +1,505 @@
|
|||
//
|
||||
// FILE: MultiSpeedI2CScanner.ino
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.1.17
|
||||
// PURPOSE: I2C scanner at different speeds
|
||||
// DATE: 2013-11-05
|
||||
// URL: https://github.com/RobTillaart/MultiSpeedI2CScanner
|
||||
// URL: http://forum.arduino.cc/index.php?topic=197360
|
||||
//
|
||||
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <Wire.h>
|
||||
|
||||
// FOR INTERNAL I2C BUS NANO 33 BLE
|
||||
// #define WIRE_IMPLEMENT_WIRE1 1
|
||||
// extern TwoWire Wire1;
|
||||
|
||||
void I2Cscan();
|
||||
void displayHelp();
|
||||
void reset();
|
||||
void setAddress();
|
||||
void setSpeed(char sp);
|
||||
char getCommand();
|
||||
|
||||
|
||||
TwoWire *wire;
|
||||
|
||||
const char version[] = "0.1.16";
|
||||
|
||||
|
||||
// INTERFACE COUNT (TESTED TEENSY 3.5 AND ARDUINO DUE ONLY)
|
||||
int wirePortCount = 1;
|
||||
int selectedWirePort = 0;
|
||||
|
||||
|
||||
// scans devices from 50 to 800 KHz I2C speeds.
|
||||
// speed lower than 50 and above 400 can cause problems
|
||||
long speed[10] = { 100, 200, 300, 400 };
|
||||
int speeds;
|
||||
|
||||
int addressStart = 8;
|
||||
int addressEnd = 119;
|
||||
|
||||
|
||||
// DELAY BETWEEN TESTS
|
||||
// for delay between tests of found devices.
|
||||
#ifndef RESTORE_LATENCY
|
||||
#define RESTORE_LATENCY 5
|
||||
#endif
|
||||
|
||||
bool delayFlag = false;
|
||||
|
||||
|
||||
// MINIMIZE OUTPUT
|
||||
bool printAll = true;
|
||||
bool header = true;
|
||||
bool disableIRQ = false;
|
||||
|
||||
|
||||
// STATE MACHINE
|
||||
enum states {
|
||||
STOP, ONCE, CONT, HELP
|
||||
};
|
||||
states state = STOP;
|
||||
|
||||
|
||||
// TIMING
|
||||
uint32_t startScan;
|
||||
uint32_t stopScan;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// MAIN CODE
|
||||
//
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial);
|
||||
|
||||
Wire.begin(14,33);
|
||||
|
||||
#if defined WIRE_IMPLEMENT_WIRE1 || WIRE_INTERFACES_COUNT > 1
|
||||
Wire1.begin();
|
||||
wirePortCount++;
|
||||
#endif
|
||||
#if defined WIRE_IMPLEMENT_WIRE2 || WIRE_INTERFACES_COUNT > 2
|
||||
Wire2.begin();
|
||||
wirePortCount++;
|
||||
#endif
|
||||
#if defined WIRE_IMPLEMENT_WIRE3 || WIRE_INTERFACES_COUNT > 3
|
||||
Wire3.begin();
|
||||
wirePortCount++;
|
||||
#endif
|
||||
#if defined WIRE_IMPLEMENT_WIRE4 || WIRE_INTERFACES_COUNT > 4
|
||||
Wire4.begin();
|
||||
wirePortCount++;
|
||||
#endif
|
||||
#if defined WIRE_IMPLEMENT_WIRE5 || WIRE_INTERFACES_COUNT > 5
|
||||
Wire5.begin();
|
||||
wirePortCount++;
|
||||
#endif
|
||||
|
||||
wire = &Wire;
|
||||
|
||||
Serial.println();
|
||||
reset();
|
||||
}
|
||||
|
||||
|
||||
void loop()
|
||||
{
|
||||
yield();
|
||||
char command = getCommand();
|
||||
switch (command)
|
||||
{
|
||||
case '@':
|
||||
selectedWirePort = (selectedWirePort + 1) % wirePortCount;
|
||||
Serial.print(F("<I2C PORT=Wire"));
|
||||
Serial.print(selectedWirePort);
|
||||
Serial.println(F(">"));
|
||||
switch (selectedWirePort)
|
||||
{
|
||||
case 0:
|
||||
wire = &Wire;
|
||||
break;
|
||||
#if defined WIRE_IMPLEMENT_WIRE1 || WIRE_INTERFACES_COUNT > 1
|
||||
case 1:
|
||||
wire = &Wire1;
|
||||
break;
|
||||
#endif
|
||||
#if defined WIRE_IMPLEMENT_WIRE2 || WIRE_INTERFACES_COUNT > 2
|
||||
case 2:
|
||||
wire = &Wire2;
|
||||
break;
|
||||
#endif
|
||||
#if defined WIRE_IMPLEMENT_WIRE3 || WIRE_INTERFACES_COUNT > 3
|
||||
case 3:
|
||||
wire = &Wire3;
|
||||
break;
|
||||
#endif
|
||||
#if defined WIRE_IMPLEMENT_WIRE4 || WIRE_INTERFACES_COUNT > 4
|
||||
case 4:
|
||||
wire = &Wire4;
|
||||
break;
|
||||
#endif
|
||||
#if defined WIRE_IMPLEMENT_WIRE5 || WIRE_INTERFACES_COUNT > 5
|
||||
case 5:
|
||||
wire = &Wire5;
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
|
||||
case 's':
|
||||
state = ONCE;
|
||||
break;
|
||||
case 'c':
|
||||
state = CONT;
|
||||
break;
|
||||
case 'd':
|
||||
delayFlag = !delayFlag;
|
||||
Serial.print(F("<delay="));
|
||||
Serial.println(delayFlag ? F("5>") : F("0>"));
|
||||
break;
|
||||
|
||||
case 'e':
|
||||
// eeprom test TODO
|
||||
break;
|
||||
|
||||
case 'h':
|
||||
header = !header;
|
||||
Serial.print(F("<header="));
|
||||
Serial.println(header ? F("yes>") : F("no>"));
|
||||
break;
|
||||
case 'p':
|
||||
printAll = !printAll;
|
||||
Serial.print(F("<print="));
|
||||
Serial.println(printAll ? F("all>") : F("found>"));
|
||||
break;
|
||||
case 'i':
|
||||
disableIRQ = !disableIRQ;
|
||||
Serial.print(F("<irq="));
|
||||
Serial.println(disableIRQ ? F("diabled>") : F("enabled>"));
|
||||
break;
|
||||
|
||||
case '0':
|
||||
case '1':
|
||||
case '2':
|
||||
case '4':
|
||||
case '8':
|
||||
case '9':
|
||||
case 'M':
|
||||
case 'N':
|
||||
case 'O':
|
||||
case 'P':
|
||||
setSpeed(command);
|
||||
break;
|
||||
|
||||
case 'r':
|
||||
reset();
|
||||
break;
|
||||
|
||||
case 'a':
|
||||
setAddress();
|
||||
break;
|
||||
|
||||
case 'q':
|
||||
case '?':
|
||||
state = HELP;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
switch (state)
|
||||
{
|
||||
case ONCE:
|
||||
I2Cscan();
|
||||
state = HELP;
|
||||
break;
|
||||
case CONT:
|
||||
I2Cscan();
|
||||
delay(1000);
|
||||
break;
|
||||
case HELP:
|
||||
displayHelp();
|
||||
state = STOP;
|
||||
break;
|
||||
case STOP:
|
||||
break;
|
||||
default: // ignore all non commands
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
void reset()
|
||||
{
|
||||
setSpeed('9');
|
||||
selectedWirePort = 0;
|
||||
addressStart = 8;
|
||||
addressEnd = 119;
|
||||
|
||||
delayFlag = false;
|
||||
printAll = true;
|
||||
header = true;
|
||||
disableIRQ = false;
|
||||
|
||||
state = STOP;
|
||||
|
||||
displayHelp();
|
||||
}
|
||||
|
||||
|
||||
void setAddress()
|
||||
{
|
||||
if (addressStart == 0)
|
||||
{
|
||||
addressStart = 8;
|
||||
addressEnd = 119;
|
||||
}
|
||||
else
|
||||
{
|
||||
addressStart = 0;
|
||||
addressEnd = 127;
|
||||
}
|
||||
Serial.print(F("<address Range = "));
|
||||
Serial.print(addressStart);
|
||||
Serial.print(F(".."));
|
||||
Serial.print(addressEnd);
|
||||
Serial.println(F(">"));
|
||||
|
||||
}
|
||||
|
||||
|
||||
void setSpeed(char sp)
|
||||
{
|
||||
switch (sp)
|
||||
{
|
||||
case '1':
|
||||
speed[0] = 100;
|
||||
speeds = 1;
|
||||
break;
|
||||
case '2':
|
||||
speed[0] = 200;
|
||||
speeds = 1;
|
||||
break;
|
||||
case '4':
|
||||
speed[0] = 400;
|
||||
speeds = 1;
|
||||
break;
|
||||
case '8':
|
||||
speed[0] = 800;
|
||||
speeds = 1;
|
||||
break;
|
||||
case '9': // limited to 400 KHz
|
||||
speeds = 8;
|
||||
for (int i = 1; i <= speeds; i++) speed[i - 1] = i * 50;
|
||||
break;
|
||||
case '0': // limited to 800 KHz
|
||||
speeds = 8;
|
||||
for (int i = 1; i <= speeds; i++) speed[i - 1] = i * 100;
|
||||
break;
|
||||
|
||||
// new in 0.1.10 - experimental
|
||||
case 'M':
|
||||
speed[0] = 1000;
|
||||
speeds = 1;
|
||||
break;
|
||||
case 'N':
|
||||
speed[0] = 3400;
|
||||
speeds = 1;
|
||||
break;
|
||||
case 'O':
|
||||
speed[0] = 5000;
|
||||
speeds = 1;
|
||||
break;
|
||||
case 'P':
|
||||
speed[0] = 100;
|
||||
speed[1] = 400;
|
||||
speed[2] = 1000;
|
||||
speed[3] = 3400;
|
||||
speed[4] = 5000;
|
||||
speeds = 5;
|
||||
break;
|
||||
}
|
||||
Serial.print("<speeds =");
|
||||
for (int i = 0; i < speeds; i++)
|
||||
{
|
||||
Serial.print(' ');
|
||||
Serial.print(speed[i]);
|
||||
}
|
||||
Serial.println(" >");
|
||||
}
|
||||
|
||||
|
||||
char getCommand()
|
||||
{
|
||||
char c = '\0';
|
||||
if (Serial.available())
|
||||
{
|
||||
c = Serial.read();
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
void displayHelp()
|
||||
{
|
||||
Serial.print(F("\nArduino MultiSpeed I2C Scanner - "));
|
||||
Serial.println(version);
|
||||
Serial.println();
|
||||
Serial.print(F("I2C ports: "));
|
||||
Serial.print(wirePortCount);
|
||||
Serial.print(F(" Current: Wire"));
|
||||
Serial.println(selectedWirePort);
|
||||
Serial.println(F("\t@ = toggle Wire - Wire1 .. Wire5 [e.g. TEENSY or Arduino Due]"));
|
||||
|
||||
Serial.println(F("Scan mode:"));
|
||||
Serial.println(F("\ts = single scan"));
|
||||
Serial.println(F("\tc = continuous scan - 1 second delay"));
|
||||
Serial.println(F("\tq = quit continuous scan"));
|
||||
Serial.println(F("\td = toggle latency delay between successful tests. 0 - 5 ms"));
|
||||
Serial.println(F("\ti = toggle enable/disable interrupts"));
|
||||
|
||||
Serial.println(F("Output:"));
|
||||
Serial.println(F("\tp = toggle printAll - printFound."));
|
||||
Serial.println(F("\th = toggle header - noHeader."));
|
||||
Serial.println(F("\ta = toggle address range, 0..127 - 8..119 (default)"));
|
||||
|
||||
Serial.println(F("Speeds:"));
|
||||
Serial.println(F("\t0 = 100..800 KHz - step 100 (warning - can block!!)"));
|
||||
Serial.println(F("\t1 = 100 KHz"));
|
||||
Serial.println(F("\t2 = 200 KHz"));
|
||||
Serial.println(F("\t4 = 400 KHz"));
|
||||
Serial.println(F("\t9 = 50..400 KHz - step 50 < DEFAULT >"));
|
||||
Serial.println();
|
||||
Serial.println(F("\t!! HIGH SPEEDS - WARNING - can block - not applicable for UNO"));
|
||||
Serial.println(F("\t8 = 800 KHz"));
|
||||
Serial.println(F("\tM = 1000 KHz"));
|
||||
Serial.println(F("\tN = 3400 KHz"));
|
||||
Serial.println(F("\tO = 5000 KHz"));
|
||||
Serial.println(F("\tP = 100 400 1000 3400 5000 KHz (standards)"));
|
||||
Serial.println(F("\n\tr = reset to startup defaults."));
|
||||
Serial.println(F("\t? = help - this page"));
|
||||
Serial.println();
|
||||
}
|
||||
|
||||
|
||||
void I2Cscan()
|
||||
{
|
||||
startScan = millis();
|
||||
uint8_t count = 0;
|
||||
|
||||
if (disableIRQ)
|
||||
{
|
||||
noInterrupts();
|
||||
}
|
||||
|
||||
if (header)
|
||||
{
|
||||
Serial.print(F("TIME\tDEC\tHEX\t"));
|
||||
for (uint8_t s = 0; s < speeds; s++)
|
||||
{
|
||||
Serial.print(F("\t"));
|
||||
Serial.print(speed[s]);
|
||||
}
|
||||
Serial.println(F("\t[KHz]"));
|
||||
for (uint8_t s = 0; s < speeds + 5; s++)
|
||||
{
|
||||
Serial.print(F("--------"));
|
||||
}
|
||||
Serial.println();
|
||||
delay(100);
|
||||
}
|
||||
|
||||
for (uint8_t address = addressStart; address <= addressEnd; address++)
|
||||
{
|
||||
bool printLine = printAll;
|
||||
bool found[speeds];
|
||||
bool fnd = false;
|
||||
|
||||
for (uint8_t s = 0; s < speeds ; s++)
|
||||
{
|
||||
yield(); // keep ESP happy
|
||||
|
||||
#if ARDUINO < 158 && defined (TWBR)
|
||||
uint16_t PREV_TWBR = TWBR;
|
||||
TWBR = (F_CPU / (speed[s] * 1000) - 16) / 2;
|
||||
if (TWBR < 2)
|
||||
{
|
||||
Serial.println("ERROR: not supported speed");
|
||||
TWBR = PREV_TWBR;
|
||||
return;
|
||||
}
|
||||
#else
|
||||
wire->setClock(speed[s] * 1000UL);
|
||||
#endif
|
||||
wire->beginTransmission (address);
|
||||
found[s] = (wire->endTransmission () == 0);
|
||||
fnd |= found[s];
|
||||
// give device 5 millis
|
||||
if (fnd && delayFlag) delay(RESTORE_LATENCY);
|
||||
}
|
||||
|
||||
if (fnd) count++;
|
||||
printLine |= fnd;
|
||||
|
||||
if (printLine)
|
||||
{
|
||||
Serial.print(millis());
|
||||
Serial.print(F("\t"));
|
||||
Serial.print(address, DEC);
|
||||
Serial.print(F("\t0x"));
|
||||
if (address < 0x10) Serial.print(0, HEX);
|
||||
Serial.print(address, HEX);
|
||||
Serial.print(F("\t"));
|
||||
|
||||
for (uint8_t s = 0; s < speeds ; s++)
|
||||
{
|
||||
Serial.print(F("\t"));
|
||||
Serial.print(found[s] ? F("V") : F("."));
|
||||
}
|
||||
Serial.println();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
// FOOTER
|
||||
if (header)
|
||||
{
|
||||
for (uint8_t s = 0; s < speeds + 5; s++)
|
||||
{
|
||||
Serial.print(F("--------"));
|
||||
}
|
||||
Serial.println();
|
||||
|
||||
Serial.print(F("TIME\tDEC\tHEX\t"));
|
||||
for (uint8_t s = 0; s < speeds; s++)
|
||||
{
|
||||
Serial.print(F("\t"));
|
||||
Serial.print(speed[s]);
|
||||
}
|
||||
Serial.println(F("\t[KHz]"));
|
||||
}
|
||||
*/
|
||||
|
||||
stopScan = millis();
|
||||
if (header)
|
||||
{
|
||||
Serial.println();
|
||||
Serial.print(count);
|
||||
Serial.print(F(" devices found in "));
|
||||
Serial.print(stopScan - startScan);
|
||||
Serial.println(F(" milliseconds."));
|
||||
}
|
||||
|
||||
interrupts();
|
||||
}
|
||||
|
||||
|
||||
// -- END OF FILE --
|
22
ESPMegaPRO-firmware/src/input_demo.cpp.disabled
Normal file
22
ESPMegaPRO-firmware/src/input_demo.cpp.disabled
Normal file
|
@ -0,0 +1,22 @@
|
|||
#include <Arduino.h>
|
||||
#include <PCF8574.h>
|
||||
|
||||
PCF8574 inputbank1(0x21);
|
||||
|
||||
void setup() {
|
||||
Wire.begin(14,33);
|
||||
Serial.begin(9600);
|
||||
boolean connected = inputbank1.begin();
|
||||
Serial.println("connection state = "+String(connected));
|
||||
inputbank1.write(0, HIGH);
|
||||
delay(50);
|
||||
inputbank1.write(1, HIGH);
|
||||
delay(50);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
for(int i=2;i<8;i++) {
|
||||
Serial.println(inputbank1.read(i));
|
||||
delay(100);
|
||||
}
|
||||
}
|
17
ESPMegaPRO-firmware/src/input_test.cpp.disabled
Normal file
17
ESPMegaPRO-firmware/src/input_test.cpp.disabled
Normal file
|
@ -0,0 +1,17 @@
|
|||
#include "ESPMegaPRO.h"
|
||||
|
||||
void setup() {
|
||||
ESPMega_begin();
|
||||
Serial.begin(115200);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
if(ESPMega_digitalRead(11)) {
|
||||
ESPMega_digitalWrite(8, HIGH);
|
||||
Serial.println("11HIGH");
|
||||
} else {
|
||||
ESPMega_digitalWrite(8, LOW);
|
||||
Serial.println("11LOW");
|
||||
}
|
||||
ESPMega_loop();
|
||||
}
|
57
ESPMegaPRO-firmware/src/iot_framdemo.cpp
Normal file
57
ESPMegaPRO-firmware/src/iot_framdemo.cpp
Normal file
|
@ -0,0 +1,57 @@
|
|||
#include <ESPMegaPRO_OOP.hpp>
|
||||
#include <InternalDisplay.hpp>
|
||||
#include <ETH.h>
|
||||
|
||||
ESPMegaPRO espmega = ESPMegaPRO();
|
||||
|
||||
void input_change_callback(uint8_t pin, uint8_t value) {
|
||||
Serial.print("Input change callback: ");
|
||||
Serial.print(pin);
|
||||
Serial.print(" ");
|
||||
Serial.println(value);
|
||||
}
|
||||
|
||||
void setup() {
|
||||
espmega.begin();
|
||||
espmega.enableIotModule();
|
||||
ETH.begin();
|
||||
espmega.iot.bindEthernetInterface(Ð);
|
||||
NetworkConfig config = {
|
||||
.ip = {192, 168, 0, 11},
|
||||
.gateway = {192, 168, 0, 1},
|
||||
.subnet = {255, 255, 255, 0},
|
||||
.dns1 = {192, 168, 0, 1},
|
||||
.dns2 = {192, 168, 0, 1},
|
||||
.useStaticIp = true,
|
||||
.useWifi = false,
|
||||
.wifiUseAuth = false,
|
||||
};
|
||||
strcpy(config.ssid, "ssid");
|
||||
strcpy(config.password, "password");
|
||||
strcpy(config.hostname, "espmega");
|
||||
Serial.println("Setting network config");
|
||||
espmega.iot.setNetworkConfig(config);
|
||||
Serial.println("Connecting to network");
|
||||
espmega.iot.connectNetwork();
|
||||
Serial.println("Begin MQTT Modules");
|
||||
MqttConfig mqtt_config = {
|
||||
.mqtt_port = 1883,
|
||||
.mqtt_useauth = false
|
||||
};
|
||||
Serial.println("Setting MQTT Server");
|
||||
strcpy(mqtt_config.mqtt_server, "192.168.0.26");
|
||||
strcpy(mqtt_config.base_topic, "/espmegaoop");
|
||||
Serial.println("Loading MQTT Config Struct to IoT Module");
|
||||
espmega.iot.setMqttConfig(mqtt_config);
|
||||
Serial.println("Connecting to MQTT");
|
||||
espmega.iot.connectToMqtt();
|
||||
Serial.println("Registering cards");
|
||||
espmega.iot.registerCard(0);
|
||||
espmega.iot.registerCard(1);
|
||||
Serial.println("Initialization Routine Complete");
|
||||
espmega.inputs.registerCallback(input_change_callback);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
espmega.loop();
|
||||
}
|
38
ESPMegaPRO-firmware/src/iotdemo.cpp.disabled
Normal file
38
ESPMegaPRO-firmware/src/iotdemo.cpp.disabled
Normal file
|
@ -0,0 +1,38 @@
|
|||
#include <ESPMegaPRO_OOP.hpp>
|
||||
#include <ETH.h>
|
||||
// Instantiate ESPMega
|
||||
ESPMegaPRO espmega = ESPMegaPRO();
|
||||
|
||||
void mqtt_callback(char *topic, char *payload)
|
||||
{
|
||||
Serial.print("MQTT Callback: ");
|
||||
Serial.print(topic);
|
||||
Serial.print(" ");
|
||||
Serial.println(payload);
|
||||
}
|
||||
|
||||
IPAddress ip(192, 168, 0, 11);
|
||||
IPAddress gateway(192, 168, 0, 1);
|
||||
IPAddress subnet(255, 255, 255, 0);
|
||||
|
||||
void setup()
|
||||
{
|
||||
// Initialize ESPMega
|
||||
espmega.begin();
|
||||
espmega.enableIotModule();
|
||||
ETH.begin();
|
||||
ETH.config(ip, gateway, subnet);
|
||||
espmega.iot.setBaseTopic("/testmegaoop");
|
||||
espmega.iot.connectToMqtt("espmega", "192.168.0.26", 1883);
|
||||
espmega.iot.publishRelative("test", "test");
|
||||
espmega.iot.subscribeRelative("test");
|
||||
espmega.iot.registerMqttCallback(mqtt_callback);
|
||||
espmega.iot.registerCard(1);
|
||||
espmega.iot.publishCard(1);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
// Call ESPMega loop
|
||||
espmega.loop();
|
||||
}
|
27
ESPMegaPRO-firmware/src/ntupload.cpp.disabled
Normal file
27
ESPMegaPRO-firmware/src/ntupload.cpp.disabled
Normal file
|
@ -0,0 +1,27 @@
|
|||
#include <ESPMegaPRO.h>
|
||||
|
||||
void lcd_send_stop_bit();
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
lcd_send_stop_bit();
|
||||
Serial.print("rest");
|
||||
lcd_send_stop_bit();
|
||||
Serial.print("connect");
|
||||
lcd_send_stop_bit();
|
||||
delay(1000);
|
||||
Serial.print("whmi-wri 1024,115200,res0");
|
||||
lcd_send_stop_bit();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
while(Serial.available()) {
|
||||
Serial.write(Serial.read());
|
||||
}
|
||||
}
|
||||
|
||||
void lcd_send_stop_bit() {
|
||||
Serial.write(0xFF);
|
||||
Serial.write(0xFF);
|
||||
Serial.write(0xFF);
|
||||
}
|
28
ESPMegaPRO-firmware/src/pwm_demo.cpp.disabled
Normal file
28
ESPMegaPRO-firmware/src/pwm_demo.cpp.disabled
Normal file
|
@ -0,0 +1,28 @@
|
|||
#include <Arduino.h>
|
||||
#include "Wire.h"
|
||||
#include <Adafruit_PWMServoDriver.h>
|
||||
|
||||
Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver(0x5F);
|
||||
|
||||
void setup() {
|
||||
Wire.begin(14,33);
|
||||
pwm.begin();
|
||||
pwm.setPin(2, 500);
|
||||
pwm.setPin(3, 1000);
|
||||
pwm.setPin(4, 1500);
|
||||
pwm.setPin(5, 2000);
|
||||
pwm.setPin(6, 2500);
|
||||
pwm.setPin(7, 3000);
|
||||
pwm.setPin(8, 3500);
|
||||
pwm.setPin(9, 4000);
|
||||
pwm.setPin(10, 500);
|
||||
pwm.setPin(11, 1000);
|
||||
pwm.setPin(12, 1500);
|
||||
pwm.setPin(13, 2000);
|
||||
pwm.setPin(14, 2500);
|
||||
pwm.setPin(15, 3000);
|
||||
|
||||
}
|
||||
|
||||
void loop() {
|
||||
}
|
30
ESPMegaPRO-firmware/src/rtc_demo.cpp.disabled
Normal file
30
ESPMegaPRO-firmware/src/rtc_demo.cpp.disabled
Normal file
|
@ -0,0 +1,30 @@
|
|||
#include <ESPMegaPRO.h>
|
||||
#include <ETH.h>
|
||||
|
||||
uint8_t utc_offset = 7;
|
||||
|
||||
IPAddress IP(192, 168, 0, 241);
|
||||
IPAddress SUBNET(255, 255, 255, 0);
|
||||
IPAddress GATEWAY(192, 168, 0, 1);
|
||||
IPAddress DNS(10, 192, 1, 1);
|
||||
|
||||
void setup()
|
||||
{
|
||||
ESPMega_begin();
|
||||
Serial.begin(115200);
|
||||
ETH.begin();
|
||||
ETH.config(IP, GATEWAY, SUBNET, DNS, DNS);
|
||||
delay(5000);
|
||||
char ntp[19];
|
||||
DNS.toString().toCharArray(ntp, 19);
|
||||
ESPMega_configNTP(utc_offset * 3600, 0, ntp);
|
||||
ESPMega_updateTimeFromNTP();
|
||||
//ESPMega_setTime(0,10,52,9,11,2008);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
rtctime_t time = ESPMega_getTime();
|
||||
Serial.printf("RTC: %02d:%02d:%02d %02d/%02d/%04d\n", time.hours, time.minutes, time.seconds, time.day, time.month, time.year);
|
||||
delay(1000);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue