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...
1715526069318.png


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:
C++:
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");
  }
  Serial.println("};");
}

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
 
Hi Kurt!

My name is Justin, and I'm starting to try to utilize your very nice new library with an OV5640 Adafruit breakout (the aforementioned https://www.adafruit.com/product/5839 with some docs at https://learn.adafruit.com/adafruit-ov5640-camera-breakout/overview ) and a Teensy 4.1 without ethernet board. I would like to take an image with this OV5640, upload it from Teensy4.1 to my laptop and then display it on my laptop screen with your Processing script https://github.com/mjs513/Teensy_Ca...sualizerRawBytes/CameraVisualizerRawBytes.pde
or similar.

Your CameraVisualizerRawBytes.pde Processing script linked above states in its header

"Use with the Examples -> CameraCaptureRawBytes Arduino sketch."

However, there's no Examples -> CameraCaptureRawBytes Arduino sketch in the library (at least at present). I.e., the examples directory for your library on Github contains, at present, the Arduino sketches

Asych_pxp_framebuffer
Asych_pxp_framebuffer_a
Camera_display_tft
Camera_display_tft_vga
OV2640_display_RA8876
OV5640_display_CommandLine
OV5640_display_SDRAM_ONLY
ov2640_display

but no CameraCaptureRawBytes, and there is also nothing at present containing the string "CameraCaptureRawBytes" in the whole library (except of course the above quote "Use with the Examples -> CameraCaptureRawBytes Arduino sketch." :)

Where might I be able to find a CameraCaptureRawBytes (or similar) Arduino sketch that might work for this? (Googling for "CameraCaptureRawBytes" leads me to https://github.com/arduino-librarie...meraCaptureRawBytes/CameraCaptureRawBytes.ino , but the library, separate from your Teensy_Camera library, that that is in is for the OV767X rather than the OV5640, and there appears to be no analogue at present to that library for the OV5640.)

Thank you so much, Kurt!!! :)
Justin
 
Sorry, I have not used that sketch for a long time... If I remember correctly, there is probably one that is part of the Arducam_Dvp library.

However, I think we mostly @mjs513 has some of this functionality in some of the example sketches somewhere.
That is probably in one of the test sketches maybe not this library, which has a command to dump the frame buffer that was read in
and display it using either the PDE you mentioned or Arducam app....

But I am a bit rusty with this, maybe Mike will have better hints.
 
Sorry just catching up on forum posts now. Its been a while since i played with the camera library but looking again there is a function in the camera_display_tft_vga examp called send_raw which will allow you to send the bytes to the the visualizer sketch.

In the OV560 sketches I think I am using the Arducam windows visualizer instead of the processing sketch. I believer I added that to the extras folder in the library. If not let me know and I can add it.
 
Back
Top