Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Cojawfee
May 31, 2006
I think the US is dumb for not using Celsius
Did you test it first using a breadboard before making the PCB?

Adbot
ADBOT LOVES YOU

thehustler
Apr 17, 2004

I am very curious about this little crescendo

Cojawfee posted:

Did you test it first using a breadboard before making the PCB?

I did, I have the entire setup including the matrix on separate protoboards and it all worked fine, so I’m thinking I’ve had a manufacturing error (unlikely) or something else has gone wrong.

I guess I’ll set that all up again tomorrow and see what happens. Nothing more to be added for now really.

Edit: this, perhaps? The 1M resistor across the crystal was a late addition. https://www.avrfreaks.net/forum/atmega328p-1m-resistor-crystal

thehustler fucked around with this message at 02:00 on Jan 1, 2021

Dominoes
Sep 20, 2007

-nvm

Cojawfee
May 31, 2006
I think the US is dumb for not using Celsius
I was wondering about the resistor because I don't have one for my mcu.

sharkytm
Oct 9, 2003

Ba

By

Sharkytm doot doo do doot do doo


Fallen Rib
Get out the scope and start probing. Clock signals, pull ups/downs, comms busses, etc are likely candidates.

thehustler
Apr 17, 2004

I am very curious about this little crescendo
Resistor removal hasn’t helped so it’s over to the prototype and see if I’ve introduced a bug into the code somehow or if the chip isn’t booting.

thehustler
Apr 17, 2004

I am very curious about this little crescendo
It's my code :(

I changed a bit to optimise for space a while back and I think I broke it then. I just turned up the delay in my multiplexing loop and now I can see the flicker. It isn't lighting the lights I want, again because of the change I've made I think, but at least that's SOMETHING.

Christ, how loving embarassing. On the plus side, my PCBs work!

Edit: and now all fixed https://youtu.be/m030u5mOa08

thehustler fucked around with this message at 01:04 on Jan 2, 2021

evil_bunnY
Apr 2, 2003

thehustler posted:

Christ, how loving embarassing. On the plus side, my PCBs work!
Nah it's what happens to literally everyone.

thehustler
Apr 17, 2004

I am very curious about this little crescendo
Surprised this thread is so low traffic, but a quick question:

Everyone seems to use the SPI pins for shift registers. Do I have to? Can I use other digital pins? I have an SPI device I want to use as well.

Cojawfee
May 31, 2006
I think the US is dumb for not using Celsius

thehustler posted:

Surprised this thread is so low traffic, but a quick question:

Everyone seems to use the SPI pins for shift registers. Do I have to? Can I use other digital pins? I have an SPI device I want to use as well.

I assume they use the SPI pins because it's fast and really easy to just call up the SPI function rather than bitbanging their own implementation. A shift register is just an input and a clock, so you can do it with any of the GPIO pins, you'll just have to manually do the clock signal.

thehustler
Apr 17, 2004

I am very curious about this little crescendo

Cojawfee posted:

I assume they use the SPI pins because it's fast and really easy to just call up the SPI function rather than bitbanging their own implementation. A shift register is just an input and a clock, so you can do it with any of the GPIO pins, you'll just have to manually do the clock signal.

Thanks. I'll be using the 74HC595 but to be honest I'll probably grab a library. Which means I should probably have a look at that code to see how they're doing it under the hood.

Or I could test it, and if it all works pay no attention to it. That's always the more fun way.

Trying to make a studio clock knock-off with 60 LEDs and a MAX7219 7 segment display in the middle, with an RTC hanging off via i2c as well, so it's getting a bit busy.

Edit: One of these

ante
Apr 9, 2005

SUNSHINE AND RAINBOWS

thehustler posted:

Thanks. I'll be using the 74HC595 but to be honest I'll probably grab a library. Which means I should probably have a look at that code to see how they're doing it under the hood.


It's like, 15 lines of code to bitbang the data/clock/latch lol


If it "just works", which it might, depending on the microcontroller you're using, do that. But otherwise, just write the thing. It'll be slower than SPI, but easy to do.

thehustler
Apr 17, 2004

I am very curious about this little crescendo

ante posted:

It's like, 15 lines of code to bitbang the data/clock/latch lol


If it "just works", which it might, depending on the microcontroller you're using, do that. But otherwise, just write the thing. It'll be slower than SPI, but easy to do.

You’re right, they’re all very simple implementations.

Ok, will go that route then. I am excited about this, time to get some parts and get it breadboarded: https://www.dropbox.com/s/0zp0g8fnsibtcwy/Studio%20Clock.pdf?dl=0

Harvey Baldman
Jan 11, 2011

ATTORNEY AT LAW
Justice is bald, like an eagle, or Lady Liberty's docket.

I've got a little programming brain puzzle that I'm stuck on and I'm wondering if I can get some help.

The big picture: I have a display - a SSD1331 - being run by a Teensy 3.5. I've started using this library - SSD_13XX - and I've got things up and running for the most part. I've been able to get custom fonts working with LCD Image Converter, which can take font files or image files and turn them into a usable .c file, provided I use the template files provided with the SSD_13XX library to ensure they're formatted as expected.

I need to be able to display numbers - let's say between 30 and 0 - on the TFT, but I need them to do two things - first, they need to visually glow, which means a bit of a halo effect around the numbers. Second, they need to be able to shift from blue to red as they count down to zero.

When I talk about 'glow', this bitmap is an illustration of what I'm after:



I can get tft.print(number) to show the numbers just fine with a font or whatever, and I can change the colors from blue to red that way without a problem as it counts down, but the output is monochrome - the pixels are either on or off. This is an example of the output if I use a font and the tft.print method:



This works pretty well for what I need except I can't really get a glow effect on it. The best I can figure is that if I want to get that effect, I probably want the numbers to be bitmaps instead, since I can just have the glow as part of the image? If I take that example image above and run it through LCD Image Converter and get a .c file as output that works, and displays in color.

code:
/*******************************************************************************
* name: eighteen
*
* preset name: Color R5G6B5
* data block size: 16 bit(s), uint16_t
* RLE compression enabled: no
* conversion type: Color, not_used not_used
* bits per pixel: 16
*
* preprocess:
*  main scan direction: top_to_bottom
*  line scan direction: forward
*  inverse: no
* ------------------------------------------------------------------------------
* Created by a custom template of LCD-Image-Converter for .s.u.m.o.t.o.y.
* Image template version: 1.3
* Note: 
* ------------------------------------------------------------------------------
*******************************************************************************/
#if !defined(SUMO_IMG_LIB_eighteen)
#define SUMO_IMG_LIB_eighteen

#include <stdlib.h>

static const uint16_t image_data_eighteen[1334]
#if defined(_FORCE_PROGMEM__)
 PROGMEM 
#endif
= {0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0020, 0x0041, 0x0061, 0x0082, 0x0882, 
0x08a3, 0x08a3, 0x08c3, 0x08a3, 0x08a2, 0x0882, 0x0062, 0x0061, 0x0061, 0x0041, 0x0061, 
0x0062, 0x0882, 0x08a2, 0x08a3, 0x08c3, 0x08c3, 0x08e3, 0x08e3, 0x08e4, 0x08e4, 0x08e4, 
0x08e4, 0x08e4, 0x08e3, 0x08e3, 0x08c3, 0x08c3, 0x08a2, 0x0882, 0x0082, 0x0061, 0x0041, 
0x0020, 0x0020, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0020, 0x0041, 0x0061, 0x0882, 
0x08a3, 0x08c3, 0x08e4, 0x0904, 0x0904, 0x0904, 0x08e4, 0x08c3, 0x08a3, 0x0882, 0x0882, 
0x0882, 0x0882, 0x08a2, 0x08c3, 0x08e4, 0x0904, 0x1124, 0x1125, 0x1145, 0x1145, 0x1145, 
0x1145, 0x1145, 0x1145, 0x1145, 0x1145, 0x1125, 0x1125, 0x1104, 0x0904, 0x08e3, 0x08a3, 
0x0882, 0x0061, 0x0041, 0x0020, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0020, 0x0041, 
0x0082, 0x08a3, 0x08e4, 0x1125, 0x1145, 0x1166, 0x1166, 0x1165, 0x1145, 0x1104, 0x08e4, 
0x08c3, 0x08c3, 0x08c3, 0x08c3, 0x08e4, 0x1104, 0x1145, 0x1166, 0x1186, 0x11a7, 0x19a7, 
0x19a7, 0x19a7, 0x19a7, 0x19a7, 0x19a7, 0x19a7, 0x19a7, 0x19a7, 0x1186, 0x1186, 0x1145, 
0x1125, 0x0904, 0x08c3, 0x0882, 0x0061, 0x0041, 0x0020, 0x0000, 0x0000, 0x0000, 0x0020, 
0x0041, 0x0061, 0x08a2, 0x08e3, 0x1125, 0x1166, 0x1186, 0x19a7, 0x19c7, 0x19a7, 0x1186, 
0x1165, 0x1125, 0x0904, 0x0904, 0x0904, 0x1104, 0x1145, 0x1166, 0x1186, 0x19c7, 0x19e8, 
0x1a08, 0x1a08, 0x1a08, 0x1a08, 0x1a08, 0x1a08, 0x1a08, 0x1a08, 0x1a08, 0x1a08, 0x19e8, 
0x19c7, 0x19a7, 0x1186, 0x1145, 0x0904, 0x08c3, 0x0882, 0x0061, 0x0021, 0x0000, 0x0000, 
0x0000, 0x0020, 0x0041, 0x0062, 0x08a3, 0x0904, 0x1145, 0x4b6d, 0xdf7d, 0xdf7d, 0xdf7d, 
0xdf7d, 0xa5f8, 0x11a7, 0x1166, 0x1145, 0x1125, 0x1125, 0x1145, 0x1186, 0x19a7, 0x5bcf, 
0x95b6, 0xcf1c, 0xdf7d, 0xdf7d, 0xdf7d, 0xdf7d, 0xdf7d, 0xdf7d, 0xdf7d, 0xdf7d, 0xdf7d, 
0xdf7d, 0xdf7d, 0xb659, 0x8555, 0x3aab, 0x1186, 0x1145, 0x0904, 0x08a3, 0x0062, 0x0041, 
0x0000, 0x0000, 0x0000, 0x0020, 0x0041, 0x0082, 0x08c3, 0x1104, 0x1166, 0x4b6e, 0xdf7d, 
0xdf7d, 0xdf7d, 0xdf7d, 0xa5f8, 0x19c7, 0x11a7, 0x1166, 0x1166, 0x1166, 0x1186, 0x19c7, 
0x7cf3, 0xdf7d, 0xdf7d, 0xdf7d, 0xdf7d, 0xdf7d, 0xdf7d, 0xdf7d, 0xdf7d, 0xdf7d, 0xdf7d, 
0xdf7d, 0xdf7d, 0xdf7d, 0xdf7d, 0xdf7d, 0xdf7d, 0xcf1c, 0x3aab, 0x1186, 0x1125, 0x08c3, 
0x0882, 0x0061, 0x0000, 0x0000, 0x0000, 0x0020, 0x0041, 0x0882, 0x08c3, 0x1124, 0x1186, 
0x4b6e, 0xdf7d, 0xdf7d, 0xdf7d, 0xdf7d, 0xa5f8, 0x1a08, 0x19c7, 0x11a7, 0x1186, 0x11a7, 
0x19c7, 0x2a6a, 0xdf7d, 0xdf7d, 0xdf7d, 0xdf7d, 0xdf7d, 0xdf7d, 0xdf7d, 0xdf7d, 0xdf7d, 
0xdf7d, 0xdf7d, 0xdf7d, 0xdf7d, 0xdf7d, 0xdf7d, 0xdf7d, 0xdf7d, 0xdf7d, 0x8555, 0x19a7, 
0x1145, 0x08e4, 0x08a2, 0x0061,0x0000, 0x0000, 0x0000, 0x0020, 0x0041, 0x0082, 0x08c3, 
0x1124, 0x1186, 0x432d, 0xa5f8, 0xbeba, 0xdf7d, 0xdf7d, 0xa5f8, 0x1a09, 0x19e8, 0x19c7, 
0x19a7, 0x19c7, 0x19e8, 0x53af, 0xdf7d, 0xdf7d, 0xdf7d, 0xbeba, 0x6c92, 0x6c92, 0x6c92, 
0x6c92, 0x6c92, 0x6c92, 0x6c92, 0x6c92, 0x6c92, 0x6c92, 0x7cf4, 0xdf7d, 0xdf7d, 0xdf7d, 
0xa5f8, 0x19c7, 0x1166, 0x0904, 0x08a3, 0x0062,0x0000, 0x0000, 0x0000, 0x0020, 0x0041, 
0x0082, 0x08c3, 0x1104, 0x1166, 0x19c8, 0x1a09, 0x6c92, 0xdf7d, 0xdf7d, 0xa5f8, 0x1a09, 
0x1a08, 0x19c7, 0x19c7, 0x19c8, 0x1a08, 0x53af, 0xdf7d, 0xdf7d, 0xdf7d, 0x53af, 0x1a09, 
0x1a09, 0x1a09, 0x1a09, 0x1a09, 0x1a09, 0x1a09, 0x1a09, 0x1a09, 0x1a09, 0x1a09, 0x8d55, 
0xdf7d, 0xdf7d, 0xa5f8, 0x19e8, 0x1186, 0x1124, 0x08c3, 0x0082,0x0000, 0x0000, 0x0000, 
0x0000, 0x0041, 0x0061, 0x08a3, 0x0904, 0x1166, 0x19c7, 0x1a09, 0x6c92, 0xdf7d, 0xdf7d, 
0xa5f8, 0x1a09, 0x1a08, 0x19c8, 0x19c7, 0x19e8, 0x1a09, 0x53af, 0xdf7d, 0xdf7d, 0xdf7d, 
0x53af, 0x1a09, 0x1a09, 0x1a09, 0x1a09, 0x1a09, 0x1a09, 0x1a09, 0x1a09, 0x1a09, 0x1a09, 
0x1a09, 0x6c92, 0xdf7d, 0xdf7d, 0xa5f8, 0x19e8, 0x1186, 0x1125, 0x08c3, 0x0882,0x0000, 
0x0000, 0x0000, 0x0000, 0x0020, 0x0061, 0x08a2, 0x08e4, 0x1145, 0x19a7, 0x1a08, 0x6c92, 
0xdf7d, 0xdf7d, 0xa5f8, 0x1a09, 0x1a08, 0x19e8, 0x19c7, 0x19e8, 0x1a09, 0x53af, 0xdf7d, 
0xdf7d, 0xdf7d, 0x53af, 0x1a09, 0x1a09, 0x1a09, 0x1a09, 0x1a09, 0x1a09, 0x1a09, 0x1a09, 
0x1a09, 0x1a09, 0x1a09, 0x6c92, 0xdf7d, 0xdf7d, 0xa5f8, 0x19e8, 0x1186, 0x1125, 0x08c3, 
0x0882,0x0000, 0x0000, 0x0000, 0x0000, 0x0020, 0x0041, 0x0882, 0x08e3, 0x1145, 0x11a7, 
0x1a08, 0x6c92, 0xdf7d, 0xdf7d, 0xa5f8, 0x1a09, 0x1a08, 0x19e8, 0x19c7, 0x19e8, 0x1a09, 
0x53af, 0xdf7d, 0xdf7d, 0xdf7d, 0x53af, 0x1a09, 0x1a09, 0x1a09, 0x1a09, 0x1a09, 0x1a09, 
0x1a09, 0x1a09, 0x1a09, 0x1a09, 0x1a09, 0x6c92, 0xdf7d, 0xdf7d, 0xa5f8, 0x19e8, 0x1186, 
0x1125, 0x08c3, 0x0882,0x0000, 0x0000, 0x0000, 0x0000, 0x0020, 0x0041, 0x0882, 0x08c3, 
0x1125, 0x1186, 0x19e8, 0x6c92, 0xdf7d, 0xdf7d, 0xa5f8, 0x1a09, 0x1a08, 0x19e8, 0x19c7, 
0x19e8, 0x1a09, 0x53af, 0xdf7d, 0xdf7d, 0xdf7d, 0x5bf0, 0x1a09, 0x1a09, 0x1a09, 0x1a09, 
0x1a09, 0x1a09, 0x1a09, 0x1a09, 0x1a09, 0x1a09, 0x1a09, 0x8d55, 0xdf7d, 0xdf7d, 0xa5f8, 
0x19e8, 0x1186, 0x1125, 0x08c3, 0x0882,0x0000, 0x0000, 0x0000, 0x0000, 0x0020, 0x0041, 
0x0082, 0x08c3, 0x1124, 0x1186, 0x19e8, 0x6c92, 0xdf7d, 0xdf7d, 0xa5f8, 0x1a09, 0x1a08, 
0x19e8, 0x19c7, 0x19e8, 0x1a09, 0x3aec, 0xdf7d, 0xdf7d, 0xdf7d, 0xcf1c, 0xa5f8, 0xa5f8, 
0xa5f8, 0xa5f8, 0xa5f8, 0xa5f8, 0xa5f8, 0xa5f8, 0xa5f8, 0xa5f8, 0xb659, 0xdf7d, 0xdf7d, 
0xdf7d, 0x95b6, 0x19e8, 0x1186, 0x1125, 0x08c3, 0x0882,0x0000, 0x0000, 0x0000, 0x0000, 
0x0020, 0x0041, 0x0082, 0x08c3, 0x1124, 0x1186, 0x19e8, 0x6c92, 0xdf7d, 0xdf7d, 0xa5f8, 
0x1a09, 0x1a08, 0x19c8, 0x19c7, 0x19e8, 0x1a09, 0x1a09, 0x7cf4, 0xdf7d, 0xdf7d, 0xdf7d, 
0xdf7d, 0xdf7d, 0xdf7d, 0xdf7d, 0xdf7d, 0xdf7d, 0xdf7d, 0xdf7d, 0xdf7d, 0xdf7d, 0xdf7d, 
0xdf7d, 0xdf7d, 0xcf1c, 0x434d, 0x19e8, 0x1186, 0x1125, 0x08c3, 0x0882,0x0000, 0x0000, 
0x0000, 0x0000, 0x0020, 0x0041, 0x0082, 0x08c3, 0x1104, 0x1186, 0x19e8, 0x6c92, 0xdf7d, 
0xdf7d, 0xa5f8, 0x1a09, 0x1a08, 0x19c8, 0x19c7, 0x19e8, 0x1a09, 0x1a09, 0x6c92, 0xdf7d, 
0xdf7d, 0xdf7d, 0xdf7d, 0xdf7d, 0xdf7d, 0xdf7d, 0xdf7d, 0xdf7d, 0xdf7d, 0xdf7d, 0xdf7d, 
0xdf7d, 0xdf7d, 0xdf7d, 0xdf7d, 0xcf1c, 0x3aec, 0x19e8, 0x1186, 0x1125, 0x08c3, 0x0882,
0x0000, 0x0000, 0x0000, 0x0000, 0x0020, 0x0041, 0x0082, 0x08c3, 0x1104, 0x1186, 0x19e8, 
0x6c92, 0xdf7d, 0xdf7d, 0xa5f8, 0x1a09, 0x1a08, 0x19e8, 0x19c7, 0x19e8, 0x1a09, 0x3aec, 
0xdf7d, 0xdf7d, 0xdf7d, 0xdf7d, 0xa5f8, 0xa5f8, 0xa5f8, 0xa5f8, 0xa5f8, 0xa5f8, 0xa5f8, 
0xa5f8, 0xa5f8, 0xa5f8, 0xb659, 0xdf7d, 0xdf7d, 0xdf7d, 0x8d55, 0x19e8, 0x1186, 0x1125, 
0x08c3, 0x0882,0x0000, 0x0000, 0x0000, 0x0000, 0x0020, 0x0041, 0x0082, 0x08c3, 0x1104, 
0x1186, 0x19e8, 0x6c92, 0xdf7d, 0xdf7d, 0xa5f8, 0x1a09, 0x1a08, 0x19e8, 0x19c7, 0x19e8, 
0x1a09, 0x53af, 0xdf7d, 0xdf7d, 0xdf7d, 0x5bf0, 0x1a09, 0x1a09, 0x1a09, 0x1a09, 0x1a09, 
0x1a09, 0x1a09, 0x1a09, 0x1a09, 0x1a09, 0x1a09, 0x8d55, 0xdf7d, 0xdf7d, 0xa5f8, 0x19e8, 
0x1186, 0x1125, 0x08c3, 0x0882,0x0000, 0x0000, 0x0000, 0x0000, 0x0020, 0x0041, 0x0082, 
0x08c3, 0x1104, 0x1186, 0x19e8, 0x6c92, 0xdf7d, 0xdf7d, 0xa5f8, 0x1a09, 0x1a08, 0x19e8, 
0x19c7, 0x19e8, 0x1a09, 0x53af, 0xdf7d, 0xdf7d, 0xdf7d, 0x53af, 0x1a09, 0x1a09, 0x1a09, 
0x1a09, 0x1a09, 0x1a09, 0x1a09, 0x1a09, 0x1a09, 0x1a09, 0x1a09, 0x6c92, 0xdf7d, 0xdf7d, 
0xa5f8, 0x19e8, 0x1186, 0x1125, 0x08c3, 0x0882,0x0000, 0x0000, 0x0000, 0x0000, 0x0020, 
0x0041, 0x0082, 0x08c3, 0x1104, 0x1186, 0x19e8, 0x6c92, 0xdf7d, 0xdf7d, 0xa5f8, 0x1a09, 
0x1a08, 0x19e8, 0x19c7, 0x19e8, 0x1a09, 0x53af, 0xdf7d, 0xdf7d, 0xdf7d, 0x53af, 0x1a09, 
0x1a09, 0x1a09, 0x1a09, 0x1a09, 0x1a09, 0x1a09, 0x1a09, 0x1a09, 0x1a09, 0x1a09, 0x6c92, 
0xdf7d, 0xdf7d, 0xa5f8, 0x19e8, 0x1186, 0x1125, 0x08c3, 0x0882,0x0000, 0x0000, 0x0000, 
0x0000, 0x0020, 0x0041, 0x0082, 0x08c3, 0x1104, 0x1186, 0x19e8, 0x6c92, 0xdf7d, 0xdf7d, 
0xa5f8, 0x1a09, 0x1a08, 0x19c8, 0x19c7, 0x19e8, 0x1a09, 0x53af, 0xdf7d, 0xdf7d, 0xdf7d, 
0x53af, 0x1a09, 0x1a09, 0x1a09, 0x1a09, 0x1a09, 0x1a09, 0x1a09, 0x1a09, 0x1a09, 0x1a09, 
0x1a09, 0x6c92, 0xdf7d, 0xdf7d, 0xa5f8, 0x19e8, 0x1186, 0x1125, 0x08c3, 0x0882,0x0000, 
0x0000, 0x0000, 0x0000, 0x0020, 0x0041, 0x0062, 0x08c3, 0x1104, 0x1186, 0x19e8, 0x6c92, 
0xdf7d, 0xdf7d, 0xa5f8, 0x1a09, 0x1a08, 0x19c7, 0x19c7, 0x19c8, 0x1a08, 0x53af, 0xdf7d, 
0xdf7d, 0xdf7d, 0x53af, 0x1a09, 0x1a09, 0x1a09, 0x1a09, 0x1a09, 0x1a09, 0x1a09, 0x1a09, 
0x1a09, 0x1a09, 0x1a09, 0x8d55, 0xdf7d, 0xdf7d, 0xa5f8, 0x19e8, 0x1186, 0x1124, 0x08c3, 
0x0082,0x0000, 0x0000, 0x0000, 0x0000, 0x0020, 0x0041, 0x0062, 0x08a3, 0x0904, 0x1166, 
0x19c7, 0x6c92, 0xdf7d, 0xdf7d, 0xa5f8, 0x1a08, 0x19e8, 0x19c7, 0x19a7, 0x19c7, 0x19e8, 
0x53af, 0xdf7d, 0xdf7d, 0xdf7d, 0xb659, 0x6c92, 0x6c92, 0x6c92, 0x6c92, 0x6c92, 0x6c92, 
0x6c92, 0x6c92, 0x6c92, 0x6c92, 0x7cf4, 0xcf1c, 0xdf7d, 0xdf7d, 0xa5f8, 0x19c7, 0x1166, 
0x0904, 0x08a3, 0x0062,0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0041, 0x0061, 0x08a3, 
0x0904, 0x1165, 0x19a7, 0x6c92, 0xdf7d, 0xdf7d, 0xa5f8, 0x19e8, 0x19c7, 0x11a7, 0x1186, 
0x11a7, 0x19c7, 0x2a6a, 0xdf7d, 0xdf7d, 0xdf7d, 0xdf7d, 0xdf7d, 0xdf7d, 0xdf7d, 0xdf7d, 
0xdf7d, 0xdf7d, 0xdf7d, 0xdf7d, 0xdf7d, 0xdf7d, 0xdf7d, 0xdf7d, 0xdf7d, 0xdf7d, 0x8555, 
0x19a7, 0x1145, 0x08e4, 0x08a2, 0x0061,0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0021, 
0x0061, 0x08a2, 0x08e4, 0x1145, 0x1186, 0x6c92, 0xdf7d, 0xdf7d, 0xa5f8, 0x19c7, 0x11a7, 
0x1166, 0x1166, 0x1166, 0x1186, 0x19c7, 0x7cf3, 0xdf7d, 0xdf7d, 0xdf7d, 0xdf7d, 0xdf7d, 
0xdf7d, 0xdf7d, 0xdf7d, 0xdf7d, 0xdf7d, 0xdf7d, 0xdf7d, 0xdf7d, 0xdf7d, 0xdf7d, 0xdf7d, 
0xcf1c, 0x430c, 0x1186, 0x1125, 0x08c3, 0x0882, 0x0061,0x0000, 0x0000, 0x0000, 0x0000, 
0x0000, 0x0020, 0x0041, 0x0882, 0x08c3, 0x1124, 0x1166, 0x6c72, 0xdf7d, 0xdf7d, 0xa5f8, 
0x1186, 0x1166, 0x1145, 0x1125, 0x1145, 0x1165, 0x1186, 0x19a7, 0x6431, 0xa5f8, 0xdf7d, 
0xdf7d, 0xdf7d, 0xdf7d, 0xdf7d, 0xdf7d, 0xdf7d, 0xdf7d, 0xdf7d, 0xdf7d, 0xdf7d, 0xdf7d, 
0xbeba, 0x8555, 0x3aab, 0x1186, 0x1145, 0x0904, 0x08a3, 0x0062, 0x0041,0x0000, 0x0000, 
0x0000, 0x0000, 0x0000, 0x0020, 0x0041, 0x0062, 0x08a3, 0x08e4, 0x1125, 0x1166, 0x1186, 
0x1186, 0x1166, 0x1145, 0x1125, 0x0904, 0x0904, 0x0904, 0x1104, 0x1145, 0x1166, 0x1186, 
0x19c7, 0x19e8, 0x1a08, 0x1a08, 0x1a08, 0x1a08, 0x1a08, 0x1a08, 0x1a08, 0x1a08, 0x1a08, 
0x1a08, 0x19e8, 0x19c8, 0x19a7, 0x1186, 0x1145, 0x0904, 0x08c3, 0x0882, 0x0061, 0x0021,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0020, 0x0021, 0x0061, 0x0882, 0x08c3, 0x08e4, 
0x1104, 0x1125, 0x1125, 0x1125, 0x0904, 0x08e4, 0x08c3, 0x08c3, 0x08c3, 0x08c3, 0x08e4, 
0x1124, 0x1145, 0x1166, 0x1186, 0x11a7, 0x19a7, 0x19a7, 0x19a7, 0x19a7, 0x19a7, 0x19a7, 
0x19a7, 0x19a7, 0x19a7, 0x1186, 0x1186, 0x1145, 0x1125, 0x0904, 0x08c3, 0x0882, 0x0061, 
0x0041, 0x0020,0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0020, 0x0041, 0x0061, 
0x0882, 0x08a3, 0x08c3, 0x08e3, 0x08e3, 0x08c3, 0x08c3, 0x08a2, 0x0882, 0x0882, 0x0882, 
0x0882, 0x08a3, 0x08c3, 0x08e4, 0x0904, 0x1125, 0x1125, 0x1145, 0x1145, 0x1145, 0x1145, 
0x1145, 0x1145, 0x1145, 0x1145, 0x1145, 0x1125, 0x1104, 0x0904, 0x08e3, 0x08a3, 0x0882, 
0x0061, 0x0041, 0x0020, 0x0000};

static const tPicture eighteen = { image_data_eighteen, 46, 29, 1334, 16, RLE_no }; 

#endif
The problem with this is twofold - the glow looks a bit lovely, but I guess I could fix that with a bigger image that gradients it better to black. More importantly, though, the colors are baked in to the image array, so I can't tint it easily as it counts down unless I manually did that for every bitmap before converting it. That won't work for this because the total count that I said needed to go from 30 to 0 might sometimes be less than that - maybe from 10 to 0 - and the color shifting would already be 2/3rds done unless I had a fully separate set of images just for that countdown, which is a mess.

Is there a smarter way to accomplish what I'm after with this, or is it one of those things where I should just accept it as what it is and move on? I was wondering if there's a good way to take the drawImage function from the library I'm using and somehow make it take a color argument to tint things, but I haven't the first clue where I'd start with that.

shame on an IGA
Apr 8, 2005

Do arithmetic to the entire array, like if you wanna make it redder just add 0b0100000000000000 to every pixel value, except black if you wanna get fancy with it

Cojawfee
May 31, 2006
I think the US is dumb for not using Celsius
Yeah, store the numbers and glow as a greyscale image. Then you can go through pixel by pixel and set it to be whatever color you want. I don't know how quickly a teensy can do that though.

Harvey Baldman
Jan 11, 2011

ATTORNEY AT LAW
Justice is bald, like an eagle, or Lady Liberty's docket.

shame on an IGA posted:

Do arithmetic to the entire array, like if you wanna make it redder just add 0b0100000000000000 to every pixel value, except black if you wanna get fancy with it

Can you maybe expand on this a bit? Tbh I don't understand much about the actual 0x pixel values - when I've been calculating my lithe colors I've been doing it with functions that take RGB565 and spit out a red, green, and blue integer that I can do math I understand with.

Cojawfee
May 31, 2006
I think the US is dumb for not using Celsius

Harvey Baldman posted:

Can you maybe expand on this a bit? Tbh I don't understand much about the actual 0x pixel values - when I've been calculating my lithe colors I've been doing it with functions that take RGB565 and spit out a red, green, and blue integer that I can do math I understand with.

Each digit in the 0x0000 number is a hex number, which is 4 bits, and the whole thing is 16 bits. The first 5 bits are the red value, the middle 6 bits are the green value, and the last 5 bits are the blue values. You can extract these values by using bit masks and shifting to the right. So if you wanted the red value, you could take a random one from the list like 0x08c3, and then you would do a bitwise and with 0xF800, and then shift it 11 bits to the right and that gives you the 5 bit red value.

Hadlock
Nov 9, 2004

Are you positive that's not an ssd1306 blue oled display? I don't think they have a brightness adjust at the pixel level

Bucnasti
Aug 14, 2012

I'll Fetch My Sarcasm Robes
I bet you could get that glow effect practically by placing a piece of glass or clear plastic over the display with a small gap in between them.

ante
Apr 9, 2005

SUNSHINE AND RAINBOWS

Hadlock posted:

Are you positive that's not an ssd1306 blue oled display? I don't think they have a brightness adjust at the pixel level

I thought that too, but seems to be this:

https://www.adafruit.com/product/684

Harvey Baldman
Jan 11, 2011

ATTORNEY AT LAW
Justice is bald, like an eagle, or Lady Liberty's docket.

Bucnasti posted:

I bet you could get that glow effect practically by placing a piece of glass or clear plastic over the display with a small gap in between them.

This is a smart idea, but I also need the rest of the stuff on the screen to be legible aside from the numbers.

ante posted:

I thought that too, but seems to be this:

https://www.adafruit.com/product/684

That's right - I should have linked the product, not the datasheet, my bad.

Harvey Baldman
Jan 11, 2011

ATTORNEY AT LAW
Justice is bald, like an eagle, or Lady Liberty's docket.

Here's a question - is it possible to set an arduino [Teensy 3.2, in my case] device up such that it runs a sketch, but when plugged into a PC would show as a USB drive with a .txt file on it?

I've got a project that I need to send off to someone, and I was just imagining that I'd love to store some variables (timers, settings, that kind of thing) in a .txt file on the device that they could tweak or edit without having to re-upload a modified sketch.

I'm not really sure where to even start searching for this kind of thing.

VictualSquid
Feb 29, 2012

Gently enveloping the target with indiscriminate love.
I think I saw something like this for esp32 once.

e: Many micropython boards operate this way as default:
http://docs.micropython.org/en/latest/pyboard/tutorial/script.html?highlight=python

VictualSquid fucked around with this message at 10:26 on Apr 14, 2021

thehustler
Apr 17, 2004

I am very curious about this little crescendo
Here’s an odd one. My rotary encoder routines work fine if I put them together in one huge poll_encoder() function. I got the bulk of them from here: https://www.allaboutcircuits.com/projects/how-to-use-a-rotary-encoder-in-a-mcu-based-project/

But if I move the “actions for after the direction has been determined” functions to a separate function determine_rotary_action() with a couple of state variables for left and right and call it after checking the direction, the timing all goes to cock and the wrong sequences are read and the direction isn’t read properly. In fact it reads only in one direction.

Is this timing-related? If I sorta hold the encoder between ten notches a bit sometimes I can get it to reverse direction for a bit until it randomly decides to only go in the other direction again.

You’ll see how I’m utilising this all in poll_encoder() to figure out whether we’re in a menu or not: https://gist.github.com/mpentler/f31f07155830d65a44302936764a82a2

Any ideas? It’s fine, I can cope with it, but I feel I should separate the reading from the actioning.

Edit: I don’t see how it’s timing as it’s technically running less code if I just have it set the left or right to true. Maybe TOO fast? I’m baffled but it’s working with it moved so this is more for interesting discussion.

thehustler fucked around with this message at 18:07 on Apr 14, 2021

ante
Apr 9, 2005

SUNSHINE AND RAINBOWS
You got a debounce in there?

thehustler
Apr 17, 2004

I am very curious about this little crescendo

ante posted:

You got a debounce in there?

Not yet, so far I’ve gotten away without one. I’m basically done with that encoder functionality though so I’m tempted to leave it.

Got a delay when I redraw screen sometimes which seems to be enough.

It’s basically perfect if it’s all in the one function - very, very few slips or not-counted turns.

Edit: I have little menus now! And rotary encoders are really cool
https://twitter.com/markpentler/status/1382383543230328836?s=21

Edit 2: can’t even find the version that didn’t work now so never mind, the chunk of code stays where it is!

thehustler fucked around with this message at 19:53 on Apr 14, 2021

Fanged Lawn Wormy
Jan 4, 2008

SQUEAK! SQUEAK! SQUEAK!
Noice

Ive thought about using an encoder/clicker/screen setup for my custom controllers at work but then I’d have to write all the menu system bullshit and variable storage and no two controllers are quite the same and aghhhh gently caress that it only ever gonna get set once and then forgotten

Throw a couple pots on and and forget about it

Dominoes
Sep 20, 2007

Hey dudes. I made a conductivity module that communicates over UART. I've got it tested and working on Raspberry Pi, and am trying to make it work on Arduino. I'm running into an issue where I believe the Serial Monitor is interfering with the UART lines, as it appears they're connected. ("On Uno, Nano, Mini, and Mega, pins 0 and 1 are used for communication with the computer. Connecting anything to these pins can interfere with that communication, including causing failed uploads to the board.".

How can I test and debug this module? My C/++ isn't great, so it's possible there are bugs in the code, but I'm not sure how to test and troubleshoot. Currently, I'm getting a mix of sync errors, and no response on the terminal, and missing response or bogus chars on the Serial Monitor. Thank you. Ideally future iterations will be I2C, but I'm not sure how to make an I2C slave device at this time

Example code:

Lib:
C++ code:
    // Serial.write(MSG_START_BITS + {10} + {0, 0, 0, 0, 0, 0, 0} + MSG_END_BITS);
    // todo: Trouble finding clean way to concat this, so write the whole thing out.
    uint8_t msg[MSG_SIZE_EC] = {100, 150, 10, 0, 0, 0, 0, 0, 0, 0, 200};
    Serial.write(msg, MSG_SIZE_EC);
    
    uint8_t response[RESPONSE_SIZE_EC];
    if (Serial.available()) {
        Serial.readBytes(response, RESPONSE_SIZE_EC);
        if (response == ERROR_MSG response[0] != OK_BIT) {
            Serial.write("Error reading conductivity");
            return 0.;
        }
    } else {
        Serial.write("Problem getting data");
        return 0.;
    }

    // code that calcs K_val.

    uint16_t val = ((uint16_t)response[2] << 8) | response[1];
    return float(val) * K_val;  // µS/cm
}
Example user code:
C++ code:
#include <Anyleaf.h>

EcSensor ecSensor;

void setup(void) {
    Serial.begin(9600);

    ecSensor = EcSensor(1.0); // Set K = 1.0
}

void loop(void) {
    Serial.print("Conductivity: "); Serial.println(ecSensor.read());

    delay(1000);
}
I'm pretty sure the firmware flashed on to the sensor is fine, since it works on Raspberry Pi, so I may not delay shipping over this (most users are on Pi), but would like to sort this out when I can.

Dominoes fucked around with this message at 18:37 on May 3, 2021

babyeatingpsychopath
Oct 28, 2000
Forum Veteran



What specific arduino board? Connect your module to Serial1 if it's available, or SoftwareSerial if not. SoftwareSerial works pretty OK for lightly-to-moderately loaded ATMEGA328p boards up to 9600 baud.

You can't do full duplex serial comms with multiple transcievers on the same wire pair unless all senders know everything. This is historically what DTR/CTS and the other lines in a serial cable are for. This is almost certainly not what you want to try to implement here for testing.

If your sensor requires some input before it gives output, there's no real way to do this cleanly with only one UART/serial pair. If your sensor does NOT require input before giving output, then you can have as many "readers" on one serial line as the device's output fanout allows, but you can't have more than one writer on any line.

That is to say, coming out of a device's TX line, you can have as many RX lines connected as the TX can drive. However, there can only be one TX per physical wire.

Dominoes
Sep 20, 2007

Thank you. I'm testing using an Uno, but I'd like it to work on any Arduino. It requires input before getting output: I have a simple serial protocol set up where you send an 11-bit message to the sensor; the first 2, and last 1 bit are fixed start and stop bits. The 3rd bit is the type of message to send, and the remaining ones are data as required. So to get a reading, change a setting etc, you have to send a message from the host; then you read the response, which may be "OK, setting change worked", or a reading, encoded as a success bit + 2 u8s encoding a u16 of the reading.

It sounds like I need to wire a display etc to the Arduino to test.

I think those error prints in the above code are also inappropriate.

Dominoes fucked around with this message at 16:51 on May 3, 2021

petit choux
Feb 24, 2016

Hi, I've got some really really basic questions about arduinos, not sure where to begin. May I please start with

Is the Feather the sort of current iteration of the arduino? Or is it entirely different? Is it ready for prime time?

I came across the feather because I just discovered adafruit, I know little to nothing about them except they look like a potential path to my goal of developing and playing with accelerometers as MIDI input controllers. Is this a fairly straightforward goal? Being a cut n paste script kid, will I have a terrible time setting up the scripts, or is there code out there RN I can use straight out of the box?

Cojawfee
May 31, 2006
I think the US is dumb for not using Celsius
I think feather is Adafruit's own thing. It looks like they have boards with a bunch of different micro controllers. Arduino usually refers to a board with an Atmel micro controller. Usually some form of ATmega328 or 2560.

babyeatingpsychopath
Oct 28, 2000
Forum Veteran


petit choux posted:

Hi, I've got some really really basic questions about arduinos, not sure where to begin. May I please start with

Is the Feather the sort of current iteration of the arduino? Or is it entirely different? Is it ready for prime time?

I came across the feather because I just discovered adafruit, I know little to nothing about them except they look like a potential path to my goal of developing and playing with accelerometers as MIDI input controllers. Is this a fairly straightforward goal? Being a cut n paste script kid, will I have a terrible time setting up the scripts, or is there code out there RN I can use straight out of the box?

The Feather is Adafruit's answer to the Arduino problem: Does Thing X that says "arduino" on it work with this board? With Feather, they've made as sure as they can that all their boards are cross-compatible with all their peripherals. So if you've got a MIDI peripheral and decide to add a bunch of LEDs, it'll work. If you decide to add more LEDs and find out you don't have enough processor/memory to run everything, then you can upgrade the base board to something with more horsepower and it'll Just Work. The goal is to have the same CircuitPython code be absolutely identical across all their mainboard chipsets; they're not quite there yet, but it's close.

Feather + MIDI + accelerometer + copy/paste code is right up Feather's alley, and the Adafruit forums are pretty decent.

I helped someone with a Feather project and they didn't actually need all that much help; I've never used them myself, but not having to hand-hold a relative beginner spoke volumes for the platform.

babyeatingpsychopath
Oct 28, 2000
Forum Veteran


Dominoes posted:

Thank you. I'm testing using an Uno, but I'd like it to work on any Arduino. It requires input before getting output: I have a simple serial protocol set up where you send an 11-bit message to the sensor; the first 2, and last 1 bit are fixed start and stop bits. The 3rd bit is the type of message to send, and the remaining ones are data as required. So to get a reading, change a setting etc, you have to send a message from the host; then you read the response, which may be "OK, setting change worked", or a reading, encoded as a success bit + 2 u8s encoding a u16 of the reading.

It sounds like I need to wire a display etc to the Arduino to test.

I think those error prints in the above code are also inappropriate.

If you have an offboard usb <-> serial, then connect to your board with that and use Serial to your sensor for everything. If not, I recommend rolling something where you use softwareserial if your board doesn't have a serial1. Connect your sensor up to Serial1 and talk with it that way and keep serial free for debugging.

petit choux
Feb 24, 2016

babyeatingpsychopath posted:

The Feather is Adafruit's answer to the Arduino problem: Does Thing X that says "arduino" on it work with this board? With Feather, they've made as sure as they can that all their boards are cross-compatible with all their peripherals. So if you've got a MIDI peripheral and decide to add a bunch of LEDs, it'll work. If you decide to add more LEDs and find out you don't have enough processor/memory to run everything, then you can upgrade the base board to something with more horsepower and it'll Just Work. The goal is to have the same CircuitPython code be absolutely identical across all their mainboard chipsets; they're not quite there yet, but it's close.

Feather + MIDI + accelerometer + copy/paste code is right up Feather's alley, and the Adafruit forums are pretty decent.

I helped someone with a Feather project and they didn't actually need all that much help; I've never used them myself, but not having to hand-hold a relative beginner spoke volumes for the platform.

Wow, this is great news. I'm currently gathering together all the hardware for a similar project with a dedicated device, a Doepfer Wheel, to work in this capacity, it might be great to do it with a feather and see how they compare. I'd like to maybe run a parts list for a feather project past this thread and see if I am doing it right. Lady Ada keeps her chips nice and cheap. Some of that stuff is amazing.

Sagebrush
Feb 26, 2012

petit choux posted:

Lady Ada keeps her chips nice and cheap.

oh boy wait until you discover aliexpress



(Adafruit is absolutely the right choice if you're a total beginner, though, because their stuff comes with extensive documentation and support and is pretty certain to work correctly out of the box. Aliexpress is the wild east)

Wibla
Feb 16, 2011

Sagebrush posted:

Aliexpress is the wild east

:laffo:

This is perfect.

Fanged Lawn Wormy
Jan 4, 2008

SQUEAK! SQUEAK! SQUEAK!
Ok so here's a dumb question:

I need to smooth out some fluctuations I'm getting on an analog input (just a dumb potentiometer). The pot controls a number that is spit out to an LED matrix display, and when I'm on the edge between two of the mapped values, it rapidly fluctuates between them. I'm a bit OK if it flips back and forth a little (say every second or two) but I also need it to stay responsive for when the slider is moved.

I know that probably my best bet is to do a rolling average: basically, store an array of values and average them, then use that for the actual reading.

What I'm not sure of is where exactly I should apply that averaging. I'm mapping that analog input from the default 0-1023 to a value between 5 and 50. Is it better to average the pre-mapped raw values, or apply the averaging post-map? Does it even matter?

Adbot
ADBOT LOVES YOU

Hadlock
Nov 9, 2004

Post your analog jitter control function here when you find out a good solution

I think mine was to just use a 1024 and then expose 256 fidelity to the end user, and ignore any input that was ~+/-7 away from the previous known value. This was for a crude flight simulator that nobody else used, though

I doubt the human eye could notice that kind of difference, but it might show up on camera as a flicker

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply