TOP Contributors

  1. MIKROE (2779 codes)
  2. Alcides Ramos (376 codes)
  3. Shawon Shahryiar (307 codes)
  4. jm_palomino (118 codes)
  5. Bugz Bensce (97 codes)
  6. S P (73 codes)
  7. dany (71 codes)
  8. MikroBUS.NET Team (35 codes)
  9. NART SCHINACKOW (34 codes)
  10. Armstrong Subero (27 codes)

Most Downloaded

  1. Timer Calculator (139560 times)
  2. FAT32 Library (72041 times)
  3. Network Ethernet Library (57254 times)
  4. USB Device Library (47607 times)
  5. Network WiFi Library (43219 times)
  6. FT800 Library (42551 times)
  7. GSM click (29930 times)
  8. mikroSDK (28292 times)
  9. PID Library (26930 times)
  10. microSD click (26309 times)
Libstock prefers package manager

Package Manager

We strongly encourage users to use Package manager for sharing their code on Libstock website, because it boosts your efficiency and leaves the end user with no room for error. [more info]

< Back
Example

Cozy Fire Example for the Mikromedia Board

Rating:

5

Author: Andrew Hazelden

Last Updated: 2016-02-18

Package Version: 1.1.0.0

Example: 1.0.0.0

Category: Gaming and Fun

Downloaded: 1412 times

Followed by: 1 user

License: MIT license  

The Cozy Fire example creates an animated fireplace for the both Mikromedia PIC32 and dsPIC33 boards. The Cozy Fire example was created to show how the VisualTFT resource collection feature can be used to create animated sprites. The code was written using VisualTFT and MikroC Pro.

No Abuse Reported

Do you want to subscribe in order to receive notifications regarding " Cozy Fire Example for the Mikromedia Board" changes.

Do you want to unsubscribe in order to stop receiving notifications regarding " Cozy Fire Example for the Mikromedia Board" changes.

Do you want to report abuse regarding " Cozy Fire Example for the Mikromedia Board".

  • Information
  • Comments (2)

Example Blog

Cozy Fire Example for the Mikromedia PIC32

I wanted to create a new example that shows how to draw animated sprites on a Microchip PIC32 microcontroller. This firmware is called Cozy Fire and it shows an image sequence of a wood stove burning firewood.

Watch on YouTube

I wrote the source code for CozyFire using VisualTFT and MikroC Pro.

Since Libstock has a 10MB upload limit I broke the Cozy Fire example into multiple parts:

PIC32 Support Files

The file 1350390597__cozy_fire_examp_mikroc_pic32.rar [3.45MB] has the final hex firmware "CozyFire.hex" and the resource file "CozyFire.RES" that holds the image sequence. It also has the CozyFire source code for MikroC Pro for PIC32.

dsPIC33 Support Files

The file 1350390639__cozy_fire_examp_mikroc_dspic.rar [3.65MB] has the final hex firmware "CozyFire.hex" and the resource file "CozyFire.RES" that holds the image sequence. It also has the CozyFire source code for MikroC Pro for dsPIC33.

VisualTFT Files

The file 1350390793__cozy_fire_examp_other_other.rar [7.77MB] has the VisualTFT project and the fireplace images used for the animated image sequence. The image sequence is 144 frames long and was created as a series of Windows bitmap images.


The compiled HEX firmware for the Cozy Fire example uses 30 kilobytes of ROM space and 1.5 kilobytes of RAM.


Cozy Fire for Mikromedia PIC32 and dsPIC33

Version 1.1 - Released Oct 16, 2012

Mikromedia Image Sequence Tips

When creating an image sequence for use with VisualTFT use the file naming convention of image###.bmp   

eg. image001.bmp to image144.bmp

The images should be loaded in Visual TFT using the resource collection icon in the toolbar. Save the images to an external VisualTFT resource file.  

The CozyFire_image_sequence.h header file creates the array named "animated_fire" that holds the name for each of the frames in the image sequence.

I looked in the file CozyFire_resources.h to find out the names that VisualTFT / MikroC used for each BMP frame in the animation.

When VisualTFT saves an external image resource to the .res file it writes the images pointer address for the image fireplace001.bmp in the resource.h file as:
#define fireplace001_bmp 0x00013F9B

If you are creating a pointer array for the images keep in mind that C code arrays start at index position 0. This also means you have to be careful of off by one errors when looping the animation.

eg. The first frame in the array begins at animated_fire[0] and image number 144 is located at animated_fire[143].

There are two ways you can create an animation using MikroC and the TFT Library. You could either use the external TFT image drawing function:
TFT_EXT_Image(19, 64, animated_fire[current_frame], 1);

or your could use the VisualTFT centric workflow of swapping the current image in the picture name attribute. In the events_code.c file you could have a button press that causes an image to be animated.

eg. If you have a VisualTFT image on the current screen named "fireplace" you could swap the picture using:


void fireplaceOnPress() {
  current_frame++;

  //Keep the animation in the frame range of 0-143
  if(current_frame>=frame_range){
    current_frame=0;
  }
  fireplace.Picture_Name = animated_fire[current_frame];
  DrawImage(&fireplace);
}


Installation

1. Install Firmware: Flash the CozyFire.hex firmware file to your Mikromedia PIC32 board.

2. Install resource file: Copy the resource file CozyFire.RES to the root folder of your Mikromedia board's Micro-SD memory card.

3. Enjoy the comfort of an animated cozy fireplace on your Mikromedia PIC32 screen.

Hardware Required

Mikromedia for PIC32 v1.10
http://www.mikroe.com/mikromedia/pic32/

Mikromedia for dsPIC33 v1.10
http://www.mikroe.com/mikromedia/dspic33/

Mikromedia for dsPIC33 v1.05
http://www.mikroe.com/mikromedia/dspic33/


Example Created by Andrew Hazelden. (c) Copyright 2012.

Email

andrew@andrewhazelden.com

Blog

http://www.andrewhazelden.com

ALSO FROM THIS AUTHOR

Building an HDR Panoramic Camera Rig

6

This project creates a DIY panoramic camera rig that is capable of capturing fully spherical high dynamic range panoramas. The project uses a modified Canon DSLR battery grip that is interfaced with a MikroElektronia Mikromedia development board. The firmware has been written in C-code using the mikroC Pro for PIC32 compiler, and VisualTFT.

[Learn More]

Using a GPS Click on a Raspberry Pi

5

gps2udp is a script that connects a MikroElektronika GPS click board via USB to a Raspberry PI. The serial GPS data is pushed out through a UDP socket onto the network interface. The GPS is set to run at 115200 baud using the stty command.

[Learn More]

ACH Thumbstick Click RPi Demo

4

The python based thumbstick.py demo allows you to read a MikroElektronika Thumbstick Click board on a Raspberry PI using the GPIO and SPI inputs via a Pi Click Shield. The Thumbstick Click board uses an SPI based MCP3204 module for reading the joystick axes and the joystick "center click" button is read using the GPIO input 17 on the Raspberry Pi.

[Learn More]