Skip to content

Commit

Permalink
Merge pull request #18 from koriwi/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
koriwi authored Nov 5, 2020
2 parents 02e352c + d53b2a4 commit ab0aefe
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 11 deletions.
13 changes: 13 additions & 0 deletions app/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,25 @@
// startup right away
#define BOOT_DELAY 0
#define CONFIG_NAME "config.bin"
#define TEMP_FILE "config.bin.tmp"
#define MAX_CACHE 32

// Change this value from 0x11 up to 0xff to reduce coil whine. different
// from display to display
#define PRE_CHARGE_PERIOD 0x11

// Minimum Brightness value for displays. If your displays image quality gets worse at lower
// brighness choose a bigger value here
#define MINIMUM_BRIGHTNESS 0x20
// #define MINIMUM_BRIGHTNESS 0x00 //almost dark, good displays only
// #define MINIMUM_BRIGHTNESS 0x30 //brightest for cheap displays

// if your screen is flickering, choose a lower number. the worse the screen, the lower the number.
#define REFRESH_FREQUENCY 0xf2
// #define REFRESH_FREQUENCY 0xf1
// #define REFRESH_FREQUENCY 0xc1
// #define REFRESH_FREQUENCY 0x80

// Pin or port numbers for SDA and SCL
// NOT THE ARDUINO PORT NUMBERS
#define BB_SDA 2 // ARDUINO:RX_PIN:D0 32U4:20:PD2
Expand Down
16 changes: 7 additions & 9 deletions app/src/FreeDeck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ void loadConfigFile() {
void initSdCard() {
int i = 0;
//, SD_SCK_MHZ(50)
while (!SD.begin(SD_CS_PIN, SD_SCK_MHZ(50)) && i <= 100) {
while (!SD.begin(SD_CS_PIN, SD_SCK_MHZ(16)) && i <= 100) {
i++;
}
if (i == 100) {
Expand All @@ -261,19 +261,18 @@ void dumpConfigFileOverSerial() {
}
}

void renameConfigFile(char const *path) {
void _renameTempFileToConfigFile(char const *path) {
if (SD.exists(path)) {
SD.remove(path);
}
configFile.rename(SD.vwd(), path);
}

void _openTempFile() {
char const *tempFile = strcat(CONFIG_NAME, ".tmp");
if (SD.exists(tempFile)) {
SD.remove(tempFile);
if (SD.exists(TEMP_FILE)) {
SD.remove(TEMP_FILE);
}
configFile = SD.open(tempFile, O_WRONLY | O_CREAT);
configFile = SD.open(TEMP_FILE, O_WRONLY | O_CREAT);
configFile.seekSet(0);
}

Expand Down Expand Up @@ -304,10 +303,9 @@ void saveNewConfigFileFromSerial() {
if (chunkLength != 0) configFile.write(input, chunkLength);

} while (chunkLength == 512);
if(chunkLength == fileSize) {
renameConfigFile(CONFIG_NAME);
if(receivedBytes == fileSize) {
_renameTempFileToConfigFile(CONFIG_NAME);
}
configFile.sync();
configFile.close();

}
Expand Down
2 changes: 1 addition & 1 deletion app/src/FreeDeck.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ void setGlobalContrast();
void loadConfigFile();
void initSdCard();
void dumpConfigFileOverSerial();
void renameConfigFile();
void _renameTempFileToConfigFile();
void saveNewConfigFileFromSerial();
void postSetup();
2 changes: 1 addition & 1 deletion app/src/OledTurboLight.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ void oledInit(uint8_t bAddr, int bFlip, int bInvert) {
unsigned char uc[4];
unsigned char oled_initbuf[] = {
0x00, 0xae, 0xa8, 0x3f, 0xd3, 0x00, 0x40, 0xa1, 0xc8, 0xda, 0x12,
0x81, 0xff, 0xa4, 0xa6, 0xd5, 0x80, 0x8d, 0x14, 0xaf, 0x20, 0x00, 0xd9, PRE_CHARGE_PERIOD};
0x81, 0xff, 0xa4, 0xa6, 0xd5, REFRESH_FREQUENCY, 0x8d, 0x14, 0xaf, 0x20, 0x00, 0xd9, PRE_CHARGE_PERIOD, 0xdb, MINIMUM_BRIGHTNESS};

oled_addr = bAddr;
I2CDDR &= ~(1 << BB_SDA);
Expand Down

0 comments on commit ab0aefe

Please sign in to comment.