Search found 1013 matches

by mnf
Thu Oct 25, 2018 8:23 pm
Forum: Flowcode V8
Topic: IO pin as variable
Replies: 5
Views: 4426

Re: IO pin as variable

The Input/Output blocks don't accept/use the variables - however using them in a calculation works perfectly.

Code: Select all

TXpin = .flag
.flag = TXpin
generates:

Code: Select all

    
    SET_PORT_PIN(B, 1, FCL_FLAG);
    FCL_FLAG = GET_PORT_PIN(B, 1);
(With TXpin set to port B1)

Martin
by mnf
Thu Oct 25, 2018 6:08 pm
Forum: Flowcode V8
Topic: IO pin as variable
Replies: 5
Views: 4426

Re: IO pin as variable

Unfortunately (I think it would be a useful feature) - FC doesn't seem to support this directly. However it is pretty easy to implement a macro to do it for you: SetPortPin.fcfx Note that this is specific for AVR (328p) processors - with ports B, C and D - and would need to be tweaked for other MCUs...
by mnf
Fri Oct 19, 2018 7:32 pm
Forum: Flowcode V8
Topic: Storing and retrieving 11KB fixed data within program code. AVR & PIC
Replies: 27
Views: 5548

Re: Storing and retrieving fixed data within program code.

Should be possible to use for menus - just need to have an offset to the start of each element. As long as this doesn't fall into a compressed run then all should be well - just need a set of pointers to (or offsets) for each graphic. Compressing each element separately and then adding to the LUT is...
by mnf
Fri Oct 19, 2018 7:39 am
Forum: Flowcode V8
Topic: Storing and retrieving 11KB fixed data within program code. AVR & PIC
Replies: 27
Views: 5548

Re: Storing and retrieving fixed data within program code.

A couple of ideas to improve the compression slightly: Don't compress runs of length 2. Currently AA 'compresses' to Esc 2 A. This is easy to implement and doesn't require any changes to the decoder. Analyse the data before compression and use the value with the lowest incidence of singletons (& run...
by mnf
Thu Oct 18, 2018 9:38 pm
Forum: Flowcode V8
Topic: Storing and retrieving 11KB fixed data within program code. AVR & PIC
Replies: 27
Views: 5548

Re: Storing and retrieving fixed data within program code.

Here is a copy of the Arduino decompress routine with your bitmap (compressed) - I've only done a quick visual inspection of the output data but it looks (very) similar to the original (as it should be - it being a lossless compression technique) rle.fcfx As is - it just outputs the data to the UART...
by mnf
Thu Oct 18, 2018 9:28 pm
Forum: Flowcode V8
Topic: Storing and retrieving 11KB fixed data within program code. AVR & PIC
Replies: 27
Views: 5548

Re: Storing and retrieving fixed data within program code.

No - the compression probably won't be run on the Arduino, - and a slight glitch - actually it compresses to 3066 bytes! (It's been a while since I used C++) Still - the code there (i'll update the above message) - would have to run on the PC - and generates the data to add to a Flowcode program LUT...
by mnf
Thu Oct 18, 2018 7:51 pm
Forum: Flowcode V8
Topic: Storing and retrieving 11KB fixed data within program code. AVR & PIC
Replies: 27
Views: 5548

Re: Storing and retrieving fixed data within program code.

Just created a simple compressor in C++ - and your data file (as above) compresses from 11476 bytes to 1700..... Amending the above RLE - program it can decompress this (and the output looks AOK) I needed to generate embedded C for the data - not enough RAM to save as an array in RAM. RLE.zip (Updat...
by mnf
Thu Oct 18, 2018 7:01 pm
Forum: Flowcode V8
Topic: Storing and retrieving 11KB fixed data within program code. AVR & PIC
Replies: 27
Views: 5548

Re: Storing and retrieving fixed data within program code.

lzo -Lempel–Ziv–Oberhumer? - yes something like but a lot simpler.... RLE - can be encoded in several ways. Here is an example using an escape character (I use 27 :-) ) followed by a count byte and then a data byte - this allows runs of up to 255 bytes to compress to 3 bytes - depending on your data...
by mnf
Thu Oct 18, 2018 3:43 pm
Forum: Flowcode V8
Topic: Storing and retrieving 11KB fixed data within program code. AVR & PIC
Replies: 27
Views: 5548

Re: Storing and retrieving fixed data within program code.

The data looks a good fit for some compression too? Even simple run length encoding would reduce the size (all those blocks of 255s)

Can you acts the data from C rather than using a LUT ?

Martin (2)
by mnf
Fri Oct 12, 2018 6:11 pm
Forum: AVR & Arduino
Topic: ATTiny85
Replies: 2
Views: 5243

Re: ATTiny85

Thanks Ben, I'll have a try with Atmel Studio - I think I had a copy installed... I don't think it's a power issue - I have the LEDs powered from a bench supply (with a cap across to limit startup problems and a common ground) and the strip of 60 is working fine when using the adafruit library... If...
by mnf
Thu Oct 11, 2018 9:24 pm
Forum: AVR & Arduino
Topic: ATTiny85
Replies: 2
Views: 5243

ATTiny85

I've been trying to get an ATTiny85 to drive a WS2812 LED strip without much success. (I got it to work for ~10 LEDs) It seems the timing is a bit out - the Adafruit library puts out a ~812kHz - but using Flowcode I'm just getting ~750kHz - looking at the output on an oscilloscope. Has anyone got an...
by mnf
Thu Oct 11, 2018 5:43 pm
Forum: Flowcode V6
Topic: Bool True/False versus 1/0
Replies: 6
Views: 5082

Re: Bool True/False versus 1/0

Just one more idea - if you tick the box in 'Project Options' - Use #if for constant decisions - then define encoder_selectie as a constant (value 1 etc)rather than using it as a variable and then assigning a value - then the unused code should be optimised out. What happens when you run the program...
by mnf
Tue Oct 09, 2018 9:17 pm
Forum: 8-Bit PIC
Topic: RESISTANCE METER
Replies: 30
Views: 18324

Re: RESISTANCE METER

Sometimes it's good to take a break and sleep on it! Computers are good at doing simple tasks - very fast! So in Ben's code - the ADC is read 10 times with a 5ms delay between each reading - so 50ms per 10 times (so still ~20 times per second - okay a little slower as the ADC read takes some time) T...
by mnf
Tue Oct 09, 2018 6:10 pm
Forum: 8-Bit PIC
Topic: RESISTANCE METER
Replies: 30
Views: 18324

Re: RESISTANCE METER

One suggestion - output some debug information to the UART. This will allow you to see what is happening in a bit more detail than on the LCD - where things keep getting overwritten. For example in Ben's example above - input voltage1 (voltage returned by ADC) & voltage2 - current sum of input volta...
by mnf
Tue Oct 09, 2018 7:51 am
Forum: Flowcode V6
Topic: Bool True/False versus 1/0
Replies: 6
Views: 5082

Re: Bool True/False versus 1/0

A few thoughts: Change encoder_selectie to a byte (rather than a bool) or use true/false (or just if encoder_selectie ) (It shouldn't make a difference - a bool is just a byte - but it makes your intentions clearer) I can't find in the code any macro where encoder_selectie is changed to a value othe...
by mnf
Mon Oct 08, 2018 8:51 am
Forum: Flowcode V6
Topic: Bool True/False versus 1/0
Replies: 6
Views: 5082

Re: Bool True/False versus 1/0

Can you post an example that demonstrates this? The names shouldn't cause a problem as Flowcode changes the names of variables to FCV_NAME or FCL_NAME depending on whether they are global or local respectively. Are you combining results If a=1 and b or other? Where some parenthesis might be needed. ...
by mnf
Sat Oct 06, 2018 9:00 am
Forum: Programming Tips & Tricks
Topic: Raspberry Pi system command.
Replies: 1
Views: 8313

Raspberry Pi system command.

One for Raspberry Pi users: Was thinking about unzipping a file on the Pi - using Flowcode.. That would be a big project and madness unless you had )a lots of time and b) someone was paying big bucks and c) lots of (hard) work. So the easy way is to use someone else's code. The good news is that thi...
by mnf
Sat Oct 06, 2018 8:39 am
Forum: Flowcode V6
Topic: Random selections
Replies: 2
Views: 2585

Re: Random selections

Hi John, What a cool (or should that be ghoul?) project.... There are many ways to achieve what you want - depending on how 'random' you want the ghosts to be: A few suggestions: 1) If the ghosts are 'started' by a sensor - then use a timer / counter and look at the value when the person trips the s...
by mnf
Wed Oct 03, 2018 7:37 pm
Forum: 8-Bit PIC
Topic: RESISTANCE METER
Replies: 30
Views: 18324

Re: RESISTANCE METER

Hmm, I tried: R1 = (Vs * R2) / Vout - R2 Where R1 is the resistor I want to find - Vs is input voltage, R2 is 10000ohm and Vout is adc read voltage Adc voltage = adc_read value * 5.0 / 1024. I've assumed input voltage (and ADC ref voltage) to be 5.0. So: In a simulation only world - I subbed in 512 ...
by mnf
Wed Oct 03, 2018 9:32 am
Forum: 8-Bit PIC
Topic: RESISTANCE METER
Replies: 30
Views: 18324

Re: RESISTANCE METER

You need to assign the return value to a string so:

str = FloatToString$(voltage3)

Where str is a variable defined as a string.

Martin
by mnf
Tue Oct 02, 2018 9:37 pm
Forum: 8-Bit PIC
Topic: RESISTANCE METER
Replies: 30
Views: 18324

Re: RESISTANCE METER

change variable voltage3 to a string but it comes up as invalid im using floattostring$(voltage3) ??
Can you post an image / chart for that - sounds like a typo / mismatched types error?

Martin
by mnf
Tue Oct 02, 2018 8:55 pm
Forum: 8-Bit PIC
Topic: RESISTANCE METER
Replies: 30
Views: 18324

Re: RESISTANCE METER

Hi,

What's coming up as invalid - ie is it compiling and something odd is displayed (NAN (Not a number), Odd chars or 'Invalid'), or is it failing to compile?

Martin
by mnf
Tue Oct 02, 2018 7:02 pm
Forum: Programming Tips & Tricks
Topic: Malloc - allocating memory
Replies: 0
Views: 7964

Malloc - allocating memory

I've added this as a sub-topic - it might be useful to some. A little background: I was looking to allocate some dynamic memory to allow a macro to take variable length parameters (arrays) - make a copy (algorithm is destructive) process the data and then return the allocated memory. All arrays are ...
by mnf
Tue Oct 02, 2018 6:12 pm
Forum: 8-Bit PIC
Topic: RESISTANCE METER
Replies: 30
Views: 18324

Re: RESISTANCE METER

I can't comment on the hardware side of things - but a couple of things software wise: 1) Converting a float to a string is easy: float.png PrintNumber just takes an integer - so the value would just show the integer part (ie 3.124 will show as 3) - this is C converting from a float to an integer fo...
by mnf
Fri Sep 28, 2018 9:50 pm
Forum: Programming Tips & Tricks
Topic: DoubleDabble Algorithm
Replies: 3
Views: 7446

Re: DoubleDabble Algorithm

So I did the reverse algorithm.. I tweaked my original to allow even bigger numbers (cos if big is good then bigger must be better). Here it converts a 78 digit number (Fermat's 8th) into a 512 bit binary number and back to a string.... Now we just need some math functions (+,-,* and if you're feeli...