printer_proto.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #ifndef PRINTER_PROTO_H
  2. #define PRINTER_PROTO_H
  3. #include <gblink/include/gblink.h>
  4. #pragma once
  5. enum cb_reason {
  6. reason_data,
  7. reason_print,
  8. reason_complete,
  9. };
  10. /* Dual purpose struct used for both receiving image data from game boy, and
  11. * sending it to printer.
  12. */
  13. struct gb_image {
  14. /* TODO: Need to understand this more */
  15. uint8_t num_sheets;
  16. uint8_t margins;
  17. /* TODO: Does this actually matter? */
  18. uint8_t palette;
  19. /* TODO: Need to play with this more */
  20. uint8_t exposure;
  21. /* Always expected to be 160 px wide */
  22. size_t data_sz;
  23. uint8_t data[];
  24. };
  25. void *printer_alloc(void);
  26. void printer_free(void *printer_handle);
  27. void printer_callback_context_set(void *printer_handle, void *context);
  28. void printer_callback_set(void *printer_handle, void (*callback)(void *context, struct gb_image *image, enum cb_reason reason));
  29. /* Can only be run after alloc, before start */
  30. int printer_pin_set_default(void *printer_handle, gblink_pinouts pinout);
  31. int printer_pin_set(void *printer_handle, gblink_bus_pins pin, const GpioPin *gpio);
  32. const GpioPin *printer_pin_get(void *printer_handle, gblink_bus_pins pin);
  33. void printer_stop(void *printer_handle);
  34. /* Allocates a buffer of the maximum size that the printer can handle, must be
  35. * freed manually. Provided as a convenience function so the application doesn't
  36. * need to know how big of a buffer to create.
  37. */
  38. struct gb_image *printer_image_buffer_alloc(void);
  39. void printer_image_buffer_free(struct gb_image *image);
  40. #endif // PRINTER_PROTO_H