Skip to content

Commit

Permalink
improvements and bug fixes. mpu heats because of unknown problem if u…
Browse files Browse the repository at this point in the history
…pdated...
  • Loading branch information
murataka committed Apr 6, 2018
1 parent 7f1e7e6 commit 3a160df
Show file tree
Hide file tree
Showing 31 changed files with 280 additions and 382 deletions.
11 changes: 10 additions & 1 deletion watchX/lib/SSD1306/oled.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
#include <Arduino.h>
#include "oled.h"

#include <SPI.h>

#include "oled.h"
unsigned char animation_offsetY=0;
unsigned char mbuf[1024]={0};
uint8_t uiX,uiY;

/*
Over a long run session, memory becomes fragmented and eventually an allocation fails
due to lack of a sufficiently large free area,
even though the total free memory is more than adequate for the request.
*/
/// TODO global left right position setting
void ssd1306_configure(){


const uint8_t s_oled128x64_initData[] =
{
SSD1306_DISPLAYOFF, // display off
Expand Down
4 changes: 2 additions & 2 deletions watchX/lib/SSD1306/oled.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@

#define uint unsigned int
//#define byte unsigned char
extern unsigned char mbuf[128*8];
extern unsigned char mbuf[1024];

extern uint8_t uiX,uiY;
extern unsigned char animation_offsetY;
void ssd1306_drawBuffer(byte x, byte y, byte w, byte h, const byte *buf);
Expand Down
8 changes: 0 additions & 8 deletions watchX/lib/buzzer/buzzer.cpp

This file was deleted.

119 changes: 0 additions & 119 deletions watchX/lib/buzzer/buzzer.h

This file was deleted.

9 changes: 0 additions & 9 deletions watchX/lib/mpu6050/gyroaccel.cpp

This file was deleted.

6 changes: 0 additions & 6 deletions watchX/lib/mpu6050/gyroaccel.h

This file was deleted.

28 changes: 28 additions & 0 deletions watchX/lib/mpu6050/tinyMpu6050.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include <Wire.h>
#include "tinyMpu6050.h"
int16_t AcX,AcY,AcZ,Tmp,GyX,GyY,GyZ;
const int MPU_addr=0x69;

void startMpu6050(){

Wire.begin();
Wire.beginTransmission(MPU_addr);
Wire.write(0x6B); // PWR_MGMT_1 register
Wire.write(0); // set to zero (wakes up the MPU-6050)
Wire.endTransmission(true);

}
void updateMpu6050(){

Wire.beginTransmission(MPU_addr);
Wire.write(0x3B); // starting with register 0x3B (ACCEL_XOUT_H)
Wire.endTransmission(false);
Wire.requestFrom(MPU_addr,14,true); // request a total of 14 registers
AcX=Wire.read()<<8|Wire.read(); // 0x3B (ACCEL_XOUT_H) & 0x3C (ACCEL_XOUT_L)
AcY=Wire.read()<<8|Wire.read(); // 0x3D (ACCEL_YOUT_H) & 0x3E (ACCEL_YOUT_L)
AcZ=Wire.read()<<8|Wire.read(); // 0x3F (ACCEL_ZOUT_H) & 0x40 (ACCEL_ZOUT_L)
Tmp=Wire.read()<<8|Wire.read(); // 0x41 (TEMP_OUT_H) & 0x42 (TEMP_OUT_L)
GyX=Wire.read()<<8|Wire.read(); // 0x43 (GYRO_XOUT_H) & 0x44 (GYRO_XOUT_L)
GyY=Wire.read()<<8|Wire.read(); // 0x45 (GYRO_YOUT_H) & 0x46 (GYRO_YOUT_L)
GyZ=Wire.read()<<8|Wire.read(); // 0x47 (GYRO_ZOUT_H) & 0x48 (GYRO_ZOUT_L)
}
8 changes: 8 additions & 0 deletions watchX/lib/mpu6050/tinyMpu6050.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#ifndef MPU6050_H
#define MPU6050_H
#include <Arduino.h>

extern int16_t AcX,AcY,AcZ,Tmp,GyX,GyY,GyZ;
void updateMpu6050();
void startMpu6050();
#endif
4 changes: 2 additions & 2 deletions watchX/lib/mpu6050/watchXmpu6050.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ bool MPU6050::begin(mpu6050_dps_t scale, mpu6050_range_t range, int mpua)
actualThreshold = 0;

// Check MPU6050 Who Am I Register
if (fastRegister8(MPU6050_REG_WHO_AM_I) != 0x69)
if (fastRegister8(MPU6050_REG_WHO_AM_I) != 0x68)
{
return false;
}
Expand Down Expand Up @@ -632,7 +632,7 @@ uint8_t MPU6050::fastRegister8(uint8_t reg)
value = Wire.read();
#else
value = Wire.receive();
#endif
#endif;
Wire.endTransmission();

return value;
Expand Down
2 changes: 1 addition & 1 deletion watchX/lib/mpu6050/watchXmpu6050.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#else
#include "WProgram.h"
#endif

#define MPU6050_ADDRESS (0x69) // 0x69 when AD0 pin to Vcc

#define MPU6050_REG_ACCEL_XOFFS_H (0x06)
Expand Down
2 changes: 2 additions & 0 deletions watchX/lib/timerone/timerone.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "timerone.h"

//func_type timerOneFunc=NULL;
/*
void startTimerOne(){
cli();//stop interrupts
Expand All @@ -19,3 +20,4 @@ ISR(TIMER1_COMPA_vect){
//if(timerOneFunc)timerOneFunc( ); /// TODO : multiple timerone handler functions
}
*/
2 changes: 1 addition & 1 deletion watchX/lib/timerone/timerone.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@

//extern func_type timerOneFunc;

void startTimerOne();
//void startTimerOne();
#endif
1 change: 1 addition & 0 deletions watchX/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@
platform = atmelavr
board = leonardo
framework = arduino
;build_flags = -Winvalid-pch -Wall -Wno-long-long -pedantic -Os -ggdb -gstabs -fdata-sections -ffunction-sections -fsigned-char -Wl,-gc-sections
6 changes: 4 additions & 2 deletions watchX/src/batteryui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
#include "oled.h"
#include "battery.h"
#include "resources.h"

void drawBattery(){



draw_bitmap( 0, 56, watchXui+(unsigned)(((batterylevel-500)/40)*16), 16, 8, false, 0);

}

}
2 changes: 1 addition & 1 deletion watchX/src/batteryui.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
#define BATTERY_UI

void drawBattery();

#endif
Loading

0 comments on commit 3a160df

Please sign in to comment.