Cleanup 3rd party samples; update README.md; add some missing copyright, fix builds for boards without certain pin definitions
This commit is contained in:
@@ -209,14 +209,14 @@ void bmp280_get_calib_params(struct bmp280_calib_param* params) {
|
||||
int main() {
|
||||
stdio_init_all();
|
||||
|
||||
// useful information for picotool
|
||||
bi_decl(bi_2pins_with_func(PICO_DEFAULT_I2C_SDA_PIN, PICO_DEFAULT_I2C_SCL_PIN, GPIO_FUNC_I2C));
|
||||
bi_decl(bi_program_description("BMP280 I2C example for the Raspberry Pi Pico"));
|
||||
|
||||
#if !defined(i2c_default) || !defined(PICO_DEFAULT_I2C_SDA_PIN) || !defined(PICO_DEFAULT_I2C_SCL_PIN)
|
||||
#warning i2c / bmp280_i2c example requires a board with I2C pins
|
||||
puts("Default I2C pins were not defined");
|
||||
#else
|
||||
// useful information for picotool
|
||||
bi_decl(bi_2pins_with_func(PICO_DEFAULT_I2C_SDA_PIN, PICO_DEFAULT_I2C_SCL_PIN, GPIO_FUNC_I2C));
|
||||
bi_decl(bi_program_description("BMP280 I2C example for the Raspberry Pi Pico"));
|
||||
|
||||
printf("Hello, BMP280! Reading temperaure and pressure values from sensor...\n");
|
||||
|
||||
// I2C is "open drain", pull ups to keep signal high when no data is being sent
|
||||
|
||||
@@ -66,7 +66,7 @@ float mcp9808_convert_temp(uint8_t upper_byte, uint8_t lower_byte) {
|
||||
return temperature;
|
||||
}
|
||||
|
||||
|
||||
#ifdef i2c_default
|
||||
void mcp9808_set_limits() {
|
||||
|
||||
//Set an upper limit of 30°C for the temperature
|
||||
@@ -97,7 +97,7 @@ void mcp9808_set_limits() {
|
||||
buf[2] = crit_temp_lsb;;
|
||||
i2c_write_blocking(i2c_default, ADDRESS, buf, 3, false);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
int main() {
|
||||
|
||||
@@ -117,7 +117,6 @@ int main() {
|
||||
gpio_pull_up(PICO_DEFAULT_I2C_SCL_PIN);
|
||||
// Make the I2C pins available to picotool
|
||||
bi_decl(bi_2pins_with_func(PICO_DEFAULT_I2C_SDA_PIN, PICO_DEFAULT_I2C_SCL_PIN, GPIO_FUNC_I2C));
|
||||
#endif
|
||||
|
||||
mcp9808_set_limits();
|
||||
|
||||
@@ -144,4 +143,5 @@ int main() {
|
||||
|
||||
sleep_ms(1000);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -56,11 +56,13 @@ float mma8451_convert_accel(uint16_t raw_accel) {
|
||||
return acceleration;
|
||||
}
|
||||
|
||||
#ifdef i2c_default
|
||||
void mma8451_set_state(uint8_t state) {
|
||||
buf[0] = REG_CTRL_REG1;
|
||||
buf[1] = state; // Set RST bit to 1
|
||||
i2c_write_blocking(i2c_default, ADDRESS, buf, 2, false);
|
||||
}
|
||||
#endif
|
||||
|
||||
int main() {
|
||||
stdio_init_all();
|
||||
|
||||
@@ -231,14 +231,14 @@ void render(uint8_t *buf, struct render_area *area) {
|
||||
int main() {
|
||||
stdio_init_all();
|
||||
|
||||
// useful information for picotool
|
||||
bi_decl(bi_2pins_with_func(PICO_DEFAULT_I2C_SDA_PIN, PICO_DEFAULT_I2C_SCL_PIN, GPIO_FUNC_I2C));
|
||||
bi_decl(bi_program_description("OLED I2C example for the Raspberry Pi Pico"));
|
||||
|
||||
#if !defined(i2c_default) || !defined(PICO_DEFAULT_I2C_SDA_PIN) || !defined(PICO_DEFAULT_I2C_SCL_PIN)
|
||||
#warning i2c / oled_i2d example requires a board with I2C pins
|
||||
puts("Default I2C pins were not defined");
|
||||
#else
|
||||
// useful information for picotool
|
||||
bi_decl(bi_2pins_with_func(PICO_DEFAULT_I2C_SDA_PIN, PICO_DEFAULT_I2C_SCL_PIN, GPIO_FUNC_I2C));
|
||||
bi_decl(bi_program_description("OLED I2C example for the Raspberry Pi Pico"));
|
||||
|
||||
printf("Hello, OLED display! Look at my raspberries..\n");
|
||||
|
||||
// I2C is "open drain", pull ups to keep signal high when no data is being
|
||||
|
||||
@@ -20,11 +20,11 @@
|
||||
GND (physical pin 38) -> GND on PCF8520 board
|
||||
*/
|
||||
|
||||
#ifdef i2c_default
|
||||
|
||||
// By default these devices are on bus address 0x68
|
||||
static int addr = 0x68;
|
||||
|
||||
#ifdef i2c_default
|
||||
|
||||
static void pcf8520_reset() {
|
||||
// Two byte reset. First byte register, second byte data
|
||||
// There are a load more options to set up the device in different ways that could be added here
|
||||
@@ -90,8 +90,6 @@ void pcf8520_set_alarm() {
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void pcf8520_check_alarm() {
|
||||
// Check bit 3 of control register 2 for alarm flags
|
||||
uint8_t status[1];
|
||||
@@ -106,6 +104,7 @@ void pcf8520_check_alarm() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void pcf8520_convert_time(int conv_time[7], const uint8_t raw_time[7]) {
|
||||
// Convert raw data into time
|
||||
conv_time[0] = (10 * (int) ((raw_time[0] & 0x70) >> 4)) + ((int) (raw_time[0] & 0x0F));
|
||||
@@ -116,6 +115,7 @@ void pcf8520_convert_time(int conv_time[7], const uint8_t raw_time[7]) {
|
||||
conv_time[5] = (10 * (int) ((raw_time[5] & 0x10) >> 4)) + ((int) (raw_time[5] & 0x0F));
|
||||
conv_time[6] = (10 * (int) ((raw_time[6] & 0xF0) >> 4)) + ((int) (raw_time[6] & 0x0F));
|
||||
}
|
||||
#endif
|
||||
|
||||
int main() {
|
||||
stdio_init_all();
|
||||
@@ -158,7 +158,7 @@ int main() {
|
||||
// Clear terminal
|
||||
printf("\e[1;1H\e[2J");
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user