New Camera Library for Teensy Micromod/4.1

Soon I will be out again doing more yard/garden work...

But thought I would mention that I wanted to get all of the cameras to work on T4.1 on the CSI pins, that worked on the Micromod with
FlexIO. The main problem child is the Arducam HM01b0 sold by Arduino as well as Arducam. The main issue with this camera was
for some reason Arducam decided to not connect up D4-D7 pins, so this camera only works in 4 bit mode.

Problem is, CSI does not support 4-bit mode. But as mentioned a few messages up, the CSI pins are also FlexIO3 pins, so... I decided to see
if I could make it work! The answer is mostly...

But, it took a few attempts with missteps... Sort of along the lines:
a) It detected that CSI would not work...
b) Checked to see if FlexIO would work. Test failed as it expected that the FlexIO Data pins were in flexio Sequence... But in this
case they are in reverse sequence. D0=15, D1=14, D2=13, D3=12.
c) Added the code to detect for this and to setup using the D3 value in this case D7 in 8-bit mode.
d) Camera still did not start up. Why the MCLK pin is not a PWM pin which the FlexIO code assumes... So detected it was on the correct
CSI pin and enabled the MCLK using the CSI stuff.
e) How to deal with the data lines reversed. In 8-bit mode, the code could simply use the SHIFTBUFBBS register instead of SHIFTBUF, that
reversed the bits in a byte. In the 4-bit mode we would need to reverse the bits in each nibble instead...

Current solution is to return the bytes in the nibble reversed order, and use a different mono-table to RGB conversion table:
I used a quick and dirty sketch to generate the table:
uint8_t bit_map_table[] = {1<<3, 1<<2, 1<<1, 1<<0, 1<<7, 1<<6, 1<<5, 1<<4};

void setup() {
  while (!Serial) {}
  Serial.print("\nstatic const uint16_t mono_palette_4bit_rev[256] PROGMEM = {\n\t");
  for (uint16_t i = 0; i <= 0xff; i++) {
    uint8_t val_in = i;
    uint8_t val_out = 0;
    for (uint8_t bit_index = 0; val_in != 0; bit_index++) {
      if (val_in & 1) val_out |= bit_map_table[bit_index];
      val_in >>= 1;
    Serial.printf("MCP(0x%02X)", val_out);
    if (i != 0xff)Serial.print(", ");
    if ((i & 0x7) == 0x7 ) Serial.print("\n\t");

void loop() {
  // put your main code here, to run repeatedly:


Will push some of this up later. Probably should confirm that most of the other cameras still work

But now time for yard...
Couldn't you just connect each input pin twice (in the order 32103210) and pretend it's regular 8-bit?
Not sure, might be interesting to try... Although my goal here is to use the same wiring to
support as many of the Arduino/Arducam/Adafruit/Waveshare cameras that have the same
breakout pinout.

If my main goal is to support the 4 bit HM01b0 on the T4.1. I would probably simply use
FlexIO. And grab a set of 4 consecutive signals on either FlexIO1 or FlexIO2. Not sure why
their module does not bring out the other 4 signals, as their HM0360 uses the same breakout
and it does...

Thanks again