M5StickC-Plus
M5StickC-Plus copied to clipboard
Infrared not functioning
I basically pasted the code with a few changes, I'm currently working on a five-screen software for my M5StickC-Plus that I want to put out when I'm done.
Does anybody have working suggestions or code for working infrared? This is what I currently have :
#include "M5_ScreenFive.h"
#include "M5_Rotate.h"
#include "includes.h"
const int ir_recv_pin = 33;
const int ir_send_pin = 9;
int last_recv_v = 0;
int curr_recv_v = 0;
void setup_IR() {
pinMode( ir_recv_pin, INPUT );
pinMode( ir_send_pin, OUTPUT );
}
void screen_three_loop( int &cursor_x, int &cursor_y ) {
unsigned char ir_code = 0;
while( true ) {
m5.update();
if( m5.BtnA.wasReleased() ) return;
m5.imu.getAhrsData( &pitch, &roll, &yaw );
if( abs( roll - proll ) > 10 ) {
rotate_screen( cursor_x, cursor_y );
proll = roll;
}
m5.lcd.setCursor( cursor_x, cursor_y );
m5.lcd.setTextSize(2);
m5.lcd.print( "___Infra___" );
if( m5.BtnB.isPressed() ) {
digitalWrite( ir_send_pin, ir_code );
m5.lcd.setCursor( cursor_x, 80 );
m5.lcd.print( "Sending IR" );
ir_code++;
m5.lcd.fillRect( cursor_x, 30, 210, 210, BLACK );
}
m5.lcd.setCursor( cursor_x, 30 );
m5.lcd.printf( "Send : 0x%02X", ir_code );
m5.lcd.setCursor( cursor_x, 50 );
curr_recv_v = digitalRead( ir_recv_pin );
if( curr_recv_v != last_recv_v ) {
m5.lcd.fillRect( cursor_x, 50, 210, 180, BLACK );
m5.lcd.printf( "Recv : 0x%02X", digitalRead( ir_recv_pin ) );
last_recv_v = curr_recv_v;
}
delay( 25 );
}
return;
}
Edit : Got output working by changing send pin from 32 to 9, now finding a bug with the speed it can send so I'm going to fix that real quick, still not sure what to do about receiving though.