serial_commands.ino 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #include "serial_commands.h"
  2. void serial_commands(CameraModel *model)
  3. {
  4. if (Serial.available() > 0)
  5. {
  6. char input = Serial.read();
  7. sensor_t *cam = esp_camera_sensor_get();
  8. switch (input)
  9. {
  10. case '>': // Toggle dithering.
  11. model->isDitheringDisabled = !model->isDitheringDisabled;
  12. break;
  13. case '<': // Toggle invert.
  14. model->isInverted = !model->isInverted;
  15. break;
  16. case 'b': // Remove brightness.
  17. cam->set_contrast(cam, cam->status.brightness - 1);
  18. break;
  19. case 'B': // Add brightness.
  20. cam->set_contrast(cam, cam->status.brightness + 1);
  21. break;
  22. case 'c': // Remove contrast.
  23. cam->set_contrast(cam, cam->status.contrast - 1);
  24. break;
  25. case 'C': // Add contrast.
  26. cam->set_contrast(cam, cam->status.contrast + 1);
  27. break;
  28. case 'f': // Turn the flash off.
  29. model->isFlashEnabled = false;
  30. pinMode(FLASH_GPIO_NUM, OUTPUT);
  31. digitalWrite(FLASH_GPIO_NUM, LOW);
  32. break;
  33. case 'F': // Turn the flash on.
  34. model->isFlashEnabled = true;
  35. pinMode(FLASH_GPIO_NUM, OUTPUT);
  36. digitalWrite(FLASH_GPIO_NUM, HIGH);
  37. break;
  38. case 'P': // Save image to the onboard SD card.
  39. // @todo - Future feature.
  40. // save_picture();
  41. break;
  42. case 'M': // Toggle Mirror.
  43. cam->set_hmirror(cam, !cam->status.hmirror);
  44. break;
  45. case 's': // Stop stream.
  46. model->isStreamEnabled = false;
  47. break;
  48. case 'S': // Start stream.
  49. model->isStreamEnabled = true;
  50. break;
  51. case '0': // Use Floyd Steinberg dithering.
  52. model->ditherAlgorithm = FLOYD_STEINBERG;
  53. break;
  54. case '1': // Use Jarvis Judice dithering.
  55. model->ditherAlgorithm = JARVIS_JUDICE_NINKE;
  56. break;
  57. case '2': // Use Stucki dithering.
  58. model->ditherAlgorithm = STUCKI;
  59. break;
  60. default:
  61. // Do nothing.
  62. break;
  63. }
  64. }
  65. }