Skip to content

Commit

Permalink
fix somes bug
Browse files Browse the repository at this point in the history
  • Loading branch information
ShallowGreen123 committed Jan 21, 2025
1 parent 9ee7691 commit fad22f2
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 93 deletions.
67 changes: 19 additions & 48 deletions examples/cc1101_send_irq/cc1101_send_irq.ino
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@

#include "TFT_eSPI.h"

#define ASSERT_FUN(name, fun) \
if (fun == RADIOLIB_ERR_INVALID_BIT_RATE) \
{ \
Serial.printf("[%s] Selected bit rate is invalid for this module\n", name); \
while (true) \
; \
}

/**
* 315MHz
* 868/915MHz
Expand All @@ -25,7 +33,7 @@ void setFlag(void)

void setup()
{
// LORA、SD and LCD use the same spi, in order to avoid mutual influence;
// LORA、SD and LCD use the same spi, in order to avoid mutual influence;
// before powering on, all CS signals should be pulled high and in an unselected state;
pinMode(TFT_CS, OUTPUT);
digitalWrite(TFT_CS, HIGH);
Expand All @@ -38,7 +46,7 @@ void setup()
Serial.begin(115200);

pinMode(BOARD_PWR_EN, OUTPUT);
digitalWrite(BOARD_PWR_EN, HIGH); // Power on CC1101 and WS2812
digitalWrite(BOARD_PWR_EN, HIGH); // Power on CC1101 and WS2812

// Set antenna frequency settings
pinMode(BOARD_LORA_SW1, OUTPUT);
Expand Down Expand Up @@ -92,62 +100,25 @@ void setup()
// and check if the configuration was changed successfully

// set carrier frequency
if (radio.setFrequency(CC1101_freq) == RADIOLIB_ERR_INVALID_FREQUENCY)
{
Serial.println(F("[CC1101] Selected frequency is invalid for this module!"));
while (true)
;
}
ASSERT_FUN("setFrequency", radio.setFrequency(CC1101_freq));

radio.setOOK(true);
if (state == RADIOLIB_ERR_INVALID_BIT_RATE)
{
Serial.println(F("[CC1101] set OOK is invalid for this module!"));
while (true)
;
}
// Enables/disables OOK modulation instead of FSK.
ASSERT_FUN("setOOK", radio.setOOK(true));

// Too high an air rate may result in data loss
// Set bit rate to 5 kbps
state = radio.setBitRate(1.2);
if (state == RADIOLIB_ERR_INVALID_BIT_RATE)
{
Serial.println(F("[CC1101] Selected bit rate is invalid for this module!"));
while (true)
;
}
ASSERT_FUN("setBitRate", radio.setBitRate(1.2));

// set receiver bandwidth to 135.0 kHz
if (radio.setRxBandwidth(58.0) == RADIOLIB_ERR_INVALID_RX_BANDWIDTH)
{
Serial.println(F("[CC1101] Selected receiver bandwidth is invalid for this module!"));
while (true)
;
}
ASSERT_FUN("setRxBandwidth", radio.setRxBandwidth(58.0));

// set allowed frequency deviation to 10.0 kHz
if (radio.setFrequencyDeviation(5.2) == RADIOLIB_ERR_INVALID_FREQUENCY_DEVIATION)
{
Serial.println(F("[CC1101] Selected frequency deviation is invalid for this module!"));
while (true)
;
}
ASSERT_FUN("setFrequencyDeviation", radio.setFrequencyDeviation(5.2));

// set output power to 10 dBm
if (radio.setOutputPower(10) == RADIOLIB_ERR_INVALID_OUTPUT_POWER)
{
Serial.println(F("[CC1101] Selected output power is invalid for this module!"));
while (true)
;
}
ASSERT_FUN("setOutputPower", radio.setOutputPower(10));

// 2 bytes can be set as sync word
if (radio.setSyncWord(0x01, 0x23) == RADIOLIB_ERR_INVALID_SYNC_WORD)
{
Serial.println(F("[CC1101] Selected sync word is invalid for this module!"));
while (true)
;
}
ASSERT_FUN("setSyncWord", radio.setSyncWord(0x01, 0x23));

// set the function that will be called
// when packet transmission is finished
Expand Down Expand Up @@ -193,7 +164,7 @@ void loop()
radio.finishTransmit();

// wait a second before transmitting again
delay(1000);
delay(500);

// send another one
Serial.print(F("[CC1101] Sending another packet ... "));
Expand Down
2 changes: 1 addition & 1 deletion examples/factory_test/factory_test.ino
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,7 @@ void setup(void)

audio.setPinout(BOARD_VOICE_BCLK, BOARD_VOICE_LRCLK, BOARD_VOICE_DIN);
audio.setVolume(21); // 0...21
audio.connecttoFS(SPIFFS, "/001.mp3");

// audio.connecttoFS(SD, "/music/My Anata.mp3");

Expand All @@ -460,7 +461,6 @@ extern bool music_is_running;

void loop(void)
{

audio.loop();

lv_timer_handler();
Expand Down
5 changes: 3 additions & 2 deletions examples/factory_test/ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <IRremoteESP8266.h>
#include <IRsend.h>
#include "peripheral/peripheral.h"
#include "utilities.h"

#define UI_THEME_DARK 0
#define UI_THEME_LIGHT 1
Expand Down Expand Up @@ -1561,8 +1562,8 @@ void batt_timer_event(lv_timer_t *t)
lv_snprintf(buf, 16, "%dmA", bq27220.getCurrent());
battery_set_line(batt_line[3], "Current:", buf);

lv_snprintf(buf, 16, "%dmv", bq27220.getChargeVoltageMax());
battery_set_line(batt_line[4], "Max Volt:", buf);
// lv_snprintf(buf, 16, "%dmv", bq27220.getChargeVoltageMax());
// battery_set_line(batt_line[4], "Max Volt:", buf);

lv_snprintf(buf, 16, "%.2f", (float)(bq27220.getTemperature() / 10.0 - 273.0));
battery_set_line(batt_line[4], "Temperature:", buf);
Expand Down
4 changes: 0 additions & 4 deletions examples/factory_test/ui.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@
#include "assets/assets.h"
#include "peripheral/peripheral.h"


#define T_EMBED_CC1101_SF_VER "v1.1-20250109"
#define T_EMBED_CC1101_HD_VER "v1.0-20240729"

// The default is landscape screen, HEIGHT and WIDTH swap
#define DISPALY_WIDTH TFT_HEIGHT
#define DISPALY_HEIGHT TFT_WIDTH
Expand Down
3 changes: 3 additions & 0 deletions examples/factory_test/utilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

#pragma once

#define T_EMBED_CC1101_SF_VER "v1.1-250109"
#define T_EMBED_CC1101_HD_VER "v1.0-240729"

#define BOARD_USER_KEY 6
#define BOARD_PWR_EN 15

Expand Down
45 changes: 7 additions & 38 deletions examples/voice_test/voice_test.ino
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include "Ticker.h"
#include "SPIFFS.h"


#define BOARD_PWR_EN 15
// Digital I/O used
#define SD_CS 13
#define SPI_MOSI 9
Expand All @@ -18,17 +18,6 @@


Audio audio;
Ticker ticker;
struct tm timeinfo;
time_t now;

uint8_t hour = 6;
uint8_t minute = 59;
uint8_t sec = 45;

bool f_time = false;
int8_t timefile = -1;
char chbuf[100];

void listDir(fs::FS &fs, const char * dirname, uint8_t levels){
Serial.printf("Listing directory: %s\r\n", dirname);
Expand Down Expand Up @@ -61,53 +50,33 @@ void listDir(fs::FS &fs, const char * dirname, uint8_t levels){
}
}


void tckr1s(){
sec++;
if(sec > 59) {sec = 0; minute++;}
if(minute > 59){minute = 0; hour++;}
if(hour > 23) {hour = 0;}
if(minute == 59 && sec == 50) f_time = true; // flag will be set 10s before full hour
Serial.printf("%02d:%02d:%02d\n", hour, minute, sec);
}

void setup() {
Serial.begin(115200);
SPI.begin(SPI_SCK, SPI_MISO, SPI_MOSI);
SD.begin(SD_CS);

pinMode(BOARD_PWR_EN, OUTPUT);
digitalWrite(BOARD_PWR_EN, HIGH); // Power on CC1101 and LED

if(!SPIFFS.begin(true)){
Serial.println("SPIFFS Mount Failed");
return;
}

listDir(SPIFFS, "/", 0);


audio.setPinout(I2S_BCLK, I2S_LRC, I2S_DOUT);
audio.setVolume(21); // 0...21
ticker.attach(1, tckr1s);

audio.connecttoFS(SPIFFS, "/001.mp3");
}

void loop(){
audio.loop();
if(f_time == true){
f_time = false;
timefile = 3;
uint8_t next_hour = hour + 1;
if(next_hour == 25) next_hour = 1;
sprintf(chbuf, "/%03d.mp3", 1);
Serial.println(chbuf);
audio.connecttoFS(SPIFFS, chbuf);
}
delay(1);
}

void audio_eof_mp3(const char *info){ //end of file
Serial.printf("file :%s\n", info);
if(timefile>0){
if(timefile==1){audio.connecttoFS(SPIFFS, "/001.mp3"); timefile--;} // stroke
if(timefile==2){audio.connecttoFS(SPIFFS, "/001.mp3"); timefile--;} // precisely
if(timefile==3){audio.connecttoFS(SPIFFS, "/001.mp3"); timefile--;}
}
audio.connecttoFS(SPIFFS, "/music.mp3");
}
Binary file added hardware/CC1101_pin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified hardware/bq27220_technical.pdf
Binary file not shown.

0 comments on commit fad22f2

Please sign in to comment.