├── .gitattributes ├── README.md └── Cardputer_as_IR_Remote_ └── Cardputer_as_IR_Remote_.ino /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | You first need to install M5Stack Boards Packages in your Arduino IDE to start using it and for that you need to paste below mentioned URL in your Arduino Preferences 2 | https://m5stack.oss-cn-shenzhen.aliyuncs.com/resource/arduino/package_m5stack_index.json 3 | -------------------------------------------------------------------------------- /Cardputer_as_IR_Remote_/Cardputer_as_IR_Remote_.ino: -------------------------------------------------------------------------------- 1 | 2 | 3 | #define DISABLE_CODE_FOR_RECEIVER // Disables restarting receiver after each 4 | // send. Saves 450 bytes program memory and 5 | // 269 bytes RAM if receiving functions are 6 | // not used. 7 | #define SEND_PWM_BY_TIMER 8 | #define IR_TX_PIN 44 9 | 10 | uint8_t sCommand = 0x34; 11 | uint8_t sRepeats = 0; 12 | 13 | 14 | #include "M5Cardputer.h" 15 | #include // include the library 16 | 17 | void setup() { 18 | auto cfg = M5.config(); 19 | M5Cardputer.begin(cfg, true); 20 | M5Cardputer.Display.setRotation(1); 21 | M5Cardputer.Display.setTextColor(GREEN); 22 | M5Cardputer.Display.setTextDatum(middle_center); 23 | M5Cardputer.Display.setTextFont(&fonts::FreeSerifBoldItalic18pt7b); 24 | M5Cardputer.Display.setTextSize(1); 25 | M5Cardputer.Display.drawString("Press a Key", 26 | M5Cardputer.Display.width() / 2, 27 | M5Cardputer.Display.height() / 2); 28 | 29 | IrSender.begin(DISABLE_LED_FEEDBACK); // Start with IR_SEND_PIN as send pin 30 | IrSender.setSendPin(IR_TX_PIN); 31 | } 32 | 33 | void loop() { 34 | M5Cardputer.update(); 35 | if (M5Cardputer.Keyboard.isChange()) { 36 | if (M5Cardputer.Keyboard.isKeyPressed('1')) 37 | { 38 | M5Cardputer.Display.clear(); 39 | M5Cardputer.Display.fillCircle(32, 105, 8, GREEN); 40 | M5Cardputer.Display.drawString("Light1", 41 | M5Cardputer.Display.width() / 2, 42 | M5Cardputer.Display.height() / 2); 43 | IrSender.sendNEC(0x80, 0xA, sRepeats); 44 | delay(500); 45 | M5Cardputer.Display.fillCircle(32, 105, 8, YELLOW); 46 | } 47 | else if (M5Cardputer.Keyboard.isKeyPressed('2')) 48 | { 49 | M5Cardputer.Display.clear(); 50 | M5Cardputer.Display.fillCircle(32, 105, 8, GREEN); 51 | M5Cardputer.Display.drawString("Light2", 52 | M5Cardputer.Display.width() / 2, 53 | M5Cardputer.Display.height() / 2); 54 | IrSender.sendNEC(0x80, 0x1B, sRepeats); 55 | delay(500); 56 | M5Cardputer.Display.fillCircle(32, 105, 8, YELLOW); 57 | } 58 | else if (M5Cardputer.Keyboard.isKeyPressed('3')) 59 | { 60 | M5Cardputer.Display.clear(); 61 | M5Cardputer.Display.fillCircle(32, 105, 8, GREEN); 62 | M5Cardputer.Display.drawString("Light3", 63 | M5Cardputer.Display.width() / 2, 64 | M5Cardputer.Display.height() / 2); 65 | IrSender.sendNEC(0x80, 0x1F, sRepeats); 66 | delay(500); 67 | M5Cardputer.Display.fillCircle(32, 105, 8, YELLOW); 68 | } 69 | else if (M5Cardputer.Keyboard.isKeyPressed('4')) 70 | { 71 | M5Cardputer.Display.clear(); 72 | M5Cardputer.Display.fillCircle(32, 105, 8, GREEN); 73 | M5Cardputer.Display.drawString("Light4", 74 | M5Cardputer.Display.width() / 2, 75 | M5Cardputer.Display.height() / 2); 76 | IrSender.sendNEC(0x80, 0xC, sRepeats); 77 | delay(500); 78 | M5Cardputer.Display.fillCircle(32, 105, 8, YELLOW); 79 | } 80 | else 81 | { 82 | M5Cardputer.Display.clear(); 83 | M5Cardputer.Display.drawString("Press Key", 84 | M5Cardputer.Display.width() / 2, 85 | M5Cardputer.Display.height() / 2); 86 | } 87 | } 88 | } 89 | --------------------------------------------------------------------------------