Skip to content

Commit

Permalink
release 0.1.9
Browse files Browse the repository at this point in the history
  • Loading branch information
Gitshaoxiang committed Jan 30, 2024
2 parents 6944a29 + d7b4461 commit 5a23ea4
Show file tree
Hide file tree
Showing 7 changed files with 254 additions and 7 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/arduino-action-compile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,20 @@ jobs:
# You may add a suffix behind the fqbn with "|" to specify one board for e.g. different compile options like arduino:avr:uno|trace
#############################################################################################################
arduino-boards-fqbn:
<<<<<<< HEAD:.github/workflows/arduino-action-compile.yml
- m5stack:esp32:m5stack_core2
=======
- m5stack:esp32:core2
>>>>>>> d7b4461c702d44503857638f1447dcb2325f0d64:.github/workflows/arduino-action-core2-compile.yml

# Specify parameters for each board.
#############################################################################################################
include:
<<<<<<< HEAD:.github/workflows/arduino-action-compile.yml
- arduino-boards-fqbn: m5stack:esp32:m5stack_core2
=======
- arduino-boards-fqbn: m5stack:esp32:core2
>>>>>>> d7b4461c702d44503857638f1447dcb2325f0d64:.github/workflows/arduino-action-core2-compile.yml
platform-url: https://m5stack.oss-cn-shenzhen.aliyuncs.com/resource/arduino/package_m5stack_index.json
sketches-exclude: WhistleSwitch,50Hz,SimpleFrequencyDetector

Expand Down
9 changes: 5 additions & 4 deletions examples/Advanced/WIFI/WiFiSetting/WebServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,11 @@ enum HTTPClientStatus { HC_NONE, HC_WAIT_READ, HC_WAIT_CLOSE };

#define HTTP_DOWNLOAD_UNIT_SIZE 1460
#define HTTP_UPLOAD_BUFLEN 2048
#define HTTP_MAX_DATA_WAIT 1000 // ms to wait for the client to send the
// request
#define HTTP_MAX_POST_WAIT 1000 // ms to wait for POST data to arrive
#define HTTP_MAX_SEND_WAIT 5000 // ms to wait for data chunk to be ACKed
#define HTTP_MAX_DATA_WAIT \
1000 // ms to wait for the client to send the
// request
#define HTTP_MAX_POST_WAIT 1000 // ms to wait for POST data to arrive
#define HTTP_MAX_SEND_WAIT 5000 // ms to wait for data chunk to be ACKed
#define HTTP_MAX_CLOSE_WAIT \
2000 // ms to wait for the client to close the connection

Expand Down
2 changes: 1 addition & 1 deletion examples/KIT/SCALES_KIT/SCALES_KIT.ino
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ confirm for calibration. 将WEIGHT UNIT连接至端口A(G32/33), 校准说
*/

#include <M5Core2.h>
#include <M5Unified.h>
#include <M5GFX.h>
#include "HX711.h"

Expand Down
148 changes: 148 additions & 0 deletions examples/Module/4EncoderMotor/4EncoderMotor.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
/**
* @file DriverSample.ino
* @author SeanKwok (shaoxiang@m5stack.com)
* @brief Module 4EncoderMotor Test Demo.
* @version 0.1
* @date 2024-01-19
*
*
* @Hardwares: M5Core2 + Module 4EncoderMotor
* @Platform Version: Arduino M5Stack Board Manager v2.1.0
* @Dependent Library:
* M5Unified: https://github.com/m5stack/M5Unified
* M5GFX: https://github.com/m5stack/M5GFX
* M5Module4EncoderMotor: https://github.com/m5stack/M5Module-4EncoderMotor
*/

#include "M5Unified.h"
#include "M5GFX.h"
#include "M5Module4EncoderMotor.h"

M5Module4EncoderMotor driver;

#define MAX_RECORD_SIZE 256

float amp_record[MAX_RECORD_SIZE] = {0};
uint8_t record_index = 0;
float amp_value = 0.0f;

uint8_t avg_filter_level = 20;

float avg_filter(float *data, int len) {
float sum = 0;
float min = data[0];
float max = data[0];
for (int i = 0; i < len; i++) {
if (data[i] < min) {
min = data[i];
}
if (data[i] > max) {
max = data[i];
}
sum += data[i];
}
sum -= min;
sum -= max;
return sum / (len - 2);
}

void setup() {
M5.begin();
M5.Display.begin();

M5.Display.setTextColor(WHITE);
M5.Display.setTextDatum(top_center);
M5.Display.setFont(&fonts::FreeSansBold12pt7b);
M5.Display.setTextSize(1);

while (!driver.begin(&Wire1, MODULE_4ENCODERMOTOR_ADDR, 21, 22)) {
Serial.println("Driver Init faild!");
M5.Display.drawString("Driver Init faild!", 160, 7);
delay(1000);
}

Serial.println("Driver Init success!");
M5.Display.clear();
M5.Display.fillRect(0, 0, 320, 35, 0x27f);
M5.Display.drawString("4Encoder Motor", 160, 7);
M5.Display.setTextDatum(top_left);

// motor channel 0 -3
for (uint8_t i = 0; i < 4; i++) {
driver.setMode(i, NORMAL_MODE);
driver.setMotorSpeed(i, 127);
}
M5.Display.drawString("NORMAL MODE", 20, 40 + 35 * 5);
}

bool direction = true;
int mode = NORMAL_MODE;

void loop() {
M5.update();
for (uint8_t i = 0; i < 4; i++) {
M5.Display.fillRect(20, 40 + 35 * i, 300, 35, BLACK);
int32_t encoder_value = driver.getEncoderValue(i);
M5.Display.drawString("CH" + String(i) + ": " + String(encoder_value),
20, 40 + 35 * i);
}

if (avg_filter_level != 0) {
amp_record[record_index] = driver.getMotorCurrent();
record_index++;
if (record_index >= avg_filter_level) {
record_index = 0;
}
amp_value = avg_filter(amp_record, avg_filter_level);
}

float voltage = driver.getAnalogInput(_8bit) / 255.0 * 3.3 / 0.16;
float current = amp_value;

M5.Display.fillRect(20, 40 + 35 * 4, 300, 35, BLACK);
M5.Display.drawString(
"POWER: " + String(voltage) + "V/" + String(current) + "A", 20,
40 + 35 * 4);

if (M5.BtnA.wasClicked() ||
(M5.Touch.getCount() && M5.Touch.getDetail(0).wasClicked())) {
mode++;
if (mode > SPEED_MODE) {
mode = NORMAL_MODE;
}
M5.Display.fillRect(20, 40 + 35 * 5, 300, 35, BLACK);

switch (mode) {
case NORMAL_MODE: {
M5.Display.drawString("NORMAL MODE", 20, 40 + 35 * 5);
// motor channel 0 -3 NORMAL_MODE
for (uint8_t i = 0; i < 4; i++) {
driver.setMode(i, NORMAL_MODE);
driver.setMotorSpeed(i, 127);
}
break;
}
case POSITION_MODE: {
M5.Display.drawString("POSITION MODE", 20, 40 + 35 * 5);
// motor channel 0 -3 POSITION_MODE

for (uint8_t i = 0; i < 4; i++) {
driver.setMode(i, POSITION_MODE);
driver.setEncoderValue(i, 0);
driver.setPostionPIDMaxSpeed(i, 127);
driver.setPositionPoint(i, 1000);
}
break;
}
case SPEED_MODE: {
M5.Display.drawString("SPEED MODE", 20, 40 + 35 * 5);
// motor channel 0 -3 SPEED_MODE
for (uint8_t i = 0; i < 4; i++) {
driver.setMode(i, SPEED_MODE);
driver.setSpeedPoint(i, 127);
}
break;
}
}
}
}
2 changes: 1 addition & 1 deletion examples/Module/COM_CAT1_SIM7680/COM_CAT1_SIM7680.ino
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ publishing. Before use, adjust the DIP switch of the module base to G16/17 ON
- [PubSubClient](https://github.com/knolleary/pubsubclient.git)
*/

#include <M5Core2.h>
#include <M5Unified.h>
#include "M5GFX.h"

// Compatible with SIM76XX series.
Expand Down
90 changes: 90 additions & 0 deletions examples/Unit/DAC2_GP8413/DAC2_GP8413.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
/**
* @file DAC2_GP8413.ino
* @author SeanKwok (shaoxiang@m5stack.com)
* @brief Core2 Unit DAC2 Test
* @version 0.1
* @date 2024-01-09
*
*
* @Hardwares: Core2 + Unit DAC2(GP8413)
* @Platform Version: Arduino M5Stack Board Manager v2.0.9
* @Dependent Library:
* M5GFX: https://github.com/m5stack/M5GFX
* M5Unified: https://github.com/m5stack/M5Unified
* DFRobot_GP8XXX: https://github.com/DFRobot/DFRobot_GP8XXX
*/

#include <M5GFX.h>
#include <M5Unified.h>
#include <DFRobot_GP8XXX.h>

DFRobot_GP8XXX_IIC GP8413(RESOLUTION_15_BIT, 0x59, &Wire);

// range is 0~10000mv
void setDacVoltage(uint16_t vol, uint8_t ch) {
uint16_t setting_vol = 0;
if (vol > 10000) {
vol = 10000;
}
if (ch > 1) ch = 1;
setting_vol = (int16_t)((float)vol / 10000.0f * 32767.0f);
if (setting_vol > 32767) {
setting_vol = 32767;
}
GP8413.setDACOutVoltage(setting_vol, ch);
}

void AllOutputCtl(uint16_t vol) {
M5.Display.fillRect(0, 0, M5.Display.width(), 30, vol > 0 ? GREEN : ORANGE);
M5.Display.drawString("OUTPUT " + String(vol) + "mv",
M5.Display.width() / 2, 0);
// set channel0
setDacVoltage(vol, 0);
// set channel1
setDacVoltage(vol, 1);
}

void setup(void) {
auto cfg = M5.config();

M5.begin(cfg);
M5.Display.setRotation(1);
M5.Display.setTextDatum(top_center);
M5.Display.setTextColor(WHITE);
M5.Display.setFont(&fonts::FreeSansBoldOblique12pt7b);
M5.Display.setTextSize(1);
M5.Display.drawString("DAC2", M5.Display.width() / 2,
M5.Display.height() / 2 - 20);
Wire.end();
Wire.begin(32, 33);

while (GP8413.begin() != 0) {
Serial.println("Init Fail!");
M5.Display.drawString("Init Fail!", M5.Display.width() / 2,
M5.Display.height() / 2);
delay(1000);
}
M5.Display.clear();
M5.Display.drawString("DAC2", M5.Display.width() / 2,
M5.Display.height() / 2 - 20);
GP8413.setDACOutRange(GP8413.eOutputRange10V);
M5.Display.drawString("Touch En/Dis Output", M5.Display.width() / 2,
M5.Display.height() / 2 + 20);

AllOutputCtl(0);
}

bool output = false;

void loop(void) {
M5.update();
if (M5.Touch.getCount() && M5.Touch.getDetail().wasPressed()) {
output = !output;
if (output) {
AllOutputCtl(3300);
// AllOutputCtl(10000);
} else {
AllOutputCtl(0);
}
}
}
2 changes: 1 addition & 1 deletion examples/Unit/LCD_ST7789V2/LCD_ST7789V2.ino
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
Please connect to Port A,Displays a string on the screen.
请连接端口A,在屏幕上显示字符串。
*/
#include <M5Core2.h>
#include <M5Unified.h>
#include <M5UnitLCD.h>

M5UnitLCD display;
Expand Down

0 comments on commit 5a23ea4

Please sign in to comment.