Jump to content



Photo
- - - - -

Useful Routines


  • Please log in to reply
10 replies to this topic

#1 flyingfisch

flyingfisch

    Casio Maniac

  • Deputy
  • PipPipPipPipPipPipPipPip
  • 1891 posts
  • Gender:Male
  • Location:OH,USA
  • Interests:Aviation, Skiing, Programming, Mountain Biking.

  • Calculators:
    fx-9860GII
    fx-CG10 PRIZM

Posted 30 June 2012 - 05:39 PM

OK, besides the fact that a lot of other forums have one of these, I want to have a place to dump code I find.

So, first one:

This will make 5-6-5 RGB for you:

uint16_t drawRGB24toRGB565(uint8_t r, uint8_t g, uint8_t <img src='/dot/public/style_emoticons/<#EMO_DIR#>/cool.png' class='bbc_emoticon' alt='B)' /> 
 { 
   return ((r / 8) << 11) | ((g / 4) << 5) | (b / 8); 
 }

Found at AdaFruit Forums

#2 Anonymouse

Anonymouse

    Casio Addict

  • Members
  • PipPipPip
  • 58 posts
  • Gender:Male

  • Calculators:
    CASIO Graph 75

Posted 19 November 2012 - 07:32 PM

That might not be optimal CPU-cycle-wise, depending on whether the compiler optimises the divisions into bit-shifts...

(also it won't compile because of the capital B )

uint16_t drawRGB24toRGB565(uint8_t r, uint8_t g, uint8_t <img src='/dot/public/style_emoticons/<#EMO_DIR#>/cool.png' class='bbc_emoticon' alt='B)' />
{
return (r >> 3 << 11) | (g >> 2 << 5) | (b >> 3);
}

  • MicroPro likes this

#3 flyingfisch

flyingfisch

    Casio Maniac

  • Deputy
  • PipPipPipPipPipPipPipPip
  • 1891 posts
  • Gender:Male
  • Location:OH,USA
  • Interests:Aviation, Skiing, Programming, Mountain Biking.

  • Calculators:
    fx-9860GII
    fx-CG10 PRIZM

Posted 19 November 2012 - 07:38 PM

Thanks for fixing my code, I didn't actually test it, so i didnt notice the capital B. :)

Probably should have, though, before posting it.

#4 shinolife63

shinolife63

    Newbie

  • Members
  • Pip
  • 24 posts
  • Gender:Male

  • Calculators:
    Hacked fx-9750gii
    fx-300 ES plus
    fx-115 ES
    fx-300 MS

Posted 22 April 2013 - 12:46 PM

I hate the way c is so particular with letter casing

#5 flyingfisch

flyingfisch

    Casio Maniac

  • Deputy
  • PipPipPipPipPipPipPipPip
  • 1891 posts
  • Gender:Male
  • Location:OH,USA
  • Interests:Aviation, Skiing, Programming, Mountain Biking.

  • Calculators:
    fx-9860GII
    fx-CG10 PRIZM

Posted 22 April 2013 - 03:01 PM

I hate the way c is so particular with letter casing


Most languages besides BASIC are particular about case. ;)

#6 shinolife63

shinolife63

    Newbie

  • Members
  • Pip
  • 24 posts
  • Gender:Male

  • Calculators:
    Hacked fx-9750gii
    fx-300 ES plus
    fx-115 ES
    fx-300 MS

Posted 22 April 2013 - 09:16 PM

Most languages besides BASIC are particular about case. ;)

I guess, Ive just always hated the c family of languadges because of the overall layout, like the stupid ";" after every line, which is why thus far ive avoided learning it

#7 flyingfisch

flyingfisch

    Casio Maniac

  • Deputy
  • PipPipPipPipPipPipPipPip
  • 1891 posts
  • Gender:Male
  • Location:OH,USA
  • Interests:Aviation, Skiing, Programming, Mountain Biking.

  • Calculators:
    fx-9860GII
    fx-CG10 PRIZM

Posted 22 April 2013 - 11:22 PM

I guess, Ive just always hated the c family of languadges because of the overall layout, like the stupid ";" after every line, which is why thus far ive avoided learning it

Yes, that does get annoying, but almost all the lower-level languages have it. C is not designed to be as user-friendly as BASIC, it's designed to be powerful. I would try LuaFX if you don't feel you are ready for C just yet. ;)

#8 shinolife63

shinolife63

    Newbie

  • Members
  • Pip
  • 24 posts
  • Gender:Male

  • Calculators:
    Hacked fx-9750gii
    fx-300 ES plus
    fx-115 ES
    fx-300 MS

Posted 22 April 2013 - 11:25 PM

Yes, that does get annoying, but almost all the lower-level languages have it. C is not designed to be as user-friendly as BASIC, it's designed to be powerful. I would try LuaFX if you don't feel you are ready for C just yet. ;)

Im kinda forced to learn it sooner or later, im going to highschool and taking classes working with circuitry, microproscesing and assembly languadge, might as well start now lol

#9 Casimo

Casimo

    Casio Overlord

  • Members
  • PipPipPipPipPipPipPip
  • 641 posts
  • Gender:Not Telling

Posted 25 April 2013 - 02:41 PM

Hey, nothing against c!
It can be very user friendly, that depends on the way you use it! And that is the fact: You do not have functions like direct hardware access in LuaFX or Basic, so it is only user friendly because you cannot do anything big with it <_<

#10 flyingfisch

flyingfisch

    Casio Maniac

  • Deputy
  • PipPipPipPipPipPipPipPip
  • 1891 posts
  • Gender:Male
  • Location:OH,USA
  • Interests:Aviation, Skiing, Programming, Mountain Biking.

  • Calculators:
    fx-9860GII
    fx-CG10 PRIZM

Posted 25 April 2013 - 03:31 PM

Hey, nothing against c!
It can be very user friendly, that depends on the way you use it! And that is the fact: You do not have functions like direct hardware access in LuaFX or Basic, so it is only user friendly because you cannot do anything big with it <_<



Depends on your idea of "big". Also, it is not just the lack of direct hardware functions that makes lua more user-friendly. It is easy to make dynamic arrays in lua, in C its much harder.

#11 Casimo

Casimo

    Casio Overlord

  • Members
  • PipPipPipPipPipPipPip
  • 641 posts
  • Gender:Not Telling

Posted 27 April 2013 - 03:37 PM

(This should be moved to an extra topic)

With "big" I mean fast, exciting games. In C, you can do everything, because LuaFX is made with C, so LuaFX cannot be better :crazy: :greengrin:

Gotta make games in asm now :lmao:




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users