Category Archives: code

Quick Unit testing with C

throwtheswitch

Unit testing is something that lots of developers are used to, and in environments like Python or Java can be even bundled in some awesome libraries. Easy to use, easy to implement, great results.

Then it comes C Embedded: The environment is different, even the people is different!!. Praising the benefits of unit testing is not that easy sometimes, even writing the unit test functions is not as straigtforward.

In this post, I’ll talk about Unity, a small unit test library for C.

See how we test

Advertisements

Leave a comment

Filed under code, tips

Arduino RTClib explained

p1403360560_ds1307_small

One of the main functionalities of the clock will be… suprise surprise, keep track of time!

For this task we’ll interface with a DS1307 RTC using the RTClib. You can just include that library and forget how it works. But that’s not the way this blog works. Let’s dive a little deeper.

How arduino RTClib works

4 Comments

Filed under code

A 3×3 font for Led Matrices

fontIcon

For the clock project I require text to appear in a small container, that is 4×4.

Since in this 4×4 I have to add vertical and horizontal spacing this ends with a 3×3 font.

Never in my life I designed a font, and if you check my hand writing… it is horrible. Luckily 3×3 only leads up to 2^9 options, 512 different characters, and I believed I could handle this.

After writing the font in a squared notebook, I checked that other fronts already exist, and, unsurprisingly they were very similar to mine.

Show me your font

Leave a comment

Filed under code, curious, DIY

ST HAL I2C address (SHIFTED!)

stlogo

Quick note, for those who might be banging their head, like I did.

ST HAL library 7 bit I2C address has to be shifted before passed to their functions.

EDIT: Let me google that for you situation. I’ve been working with the official ST documentation, when I just had to google to find this beautiful blog post from 2 years ago.

Explanation

Leave a comment

Filed under code, curious

The Scary Programming (Variable Names)

terror

Ranting is not my favorite way to express, I’m more like a constructive guy. But also, the blog is a reflection of what I’m doing right now. And for the title of the post you can guess I’m not doing a lot of GIS.

Lately I’ve been spending my time reading some questionable code, which made me think about the habits of programming. There’s no exact science here, but it is true that bad handled code can explode really fast creating a series of problems.

  • Maintenance hells.
  • A bug fixed, uncovers another bug.
  • Hard to get somebody up to speed.
  • Lots of snorting (iup that’s me).
  • Clear increase of gray hair (iup, that’s me).

I started drafting a post about this topic. Then, it exploded in size. So I decided to split it in digestible bits of enjoyment.

The original title was: The Code Apocalypse but I settled for something milder because… that’s my style :-D.

Variable Names

Leave a comment

Filed under code, tips, TSP

QDCSS : Quick and Dirty CSS Sprites

qdcss
Ah, spriting.

When I think about sprites, my mind goes directly to the NES, and SNES era.

snests4nintendones

The graphics were meshed together in a way that was easier to handle than multiple images. And well, now they have this nostalgic appeal. I can’t watch this without a smile.

Luigi Sprite from Super Mario Bros.

Luigi Sprite from Super Mario Bros.

As old as 10 years ago (already? :-O) A list apart published an amazing article on how to use this same idea to reduce the amount of browser petitions for images. That article is wonderful, but apart (hehe) from that, it urges people to think creatively!

Long story short, this is going to be a post on how to create a CSS sprite image and stylesheet with 100 lines of python.

CSS sprite generator python

Leave a comment

Filed under code, tools