ECE2035 Project 2

Dependencies:   mbed mbed-rtos SDFileSystem

Revision:
4:8e15742ebcc6
Parent:
0:bff8b9020128
Child:
5:b9b7993823e1
--- a/compost_pile.cpp	Sun Apr 04 18:02:25 2021 +0000
+++ b/compost_pile.cpp	Wed Apr 07 13:26:44 2021 +0000
@@ -9,18 +9,45 @@
 //==================================================================
 
 #include "compost_pile_private.h"
+#define X 0x00FF00 //GREEN
 
-COMPOST compost_record[NUM_PILE];
-int tallest_pile_height;
+COMPOST* compost_record[NUM_PILE];
+const int tallest_pile_height = 4;
+
+int compost_sprite[COMPOST_WIDTH * COMPOST_WIDTH] = {
+ X,X,X,X,X,X,X,X,X,X,X,
+ X,X,X,X,X,X,X,X,X,X,X,
+ X,X,X,X,X,X,X,X,X,X,X,
+ X,X,X,X,X,X,X,X,X,X,X,
+ X,X,X,X,X,X,X,X,X,X,X,
+ X,X,X,X,X,X,X,X,X,X,X,
+ X,X,X,X,X,X,X,X,X,X,X,
+ X,X,X,X,X,X,X,X,X,X,X,
+ X,X,X,X,X,X,X,X,X,X,X,
+ X,X,X,X,X,X,X,X,X,X,X,
+ X,X,X,X,X,X,X,X,X,X,X,
+ 
+};
 
 
 // See the comments in compost_pile_public.h
 void compost_pile_init() {
+    int x = 6;
+    for (int i = 0; i < NUM_PILE; i++) {
+        compost_record[i] = (COMPOST*)malloc(sizeof(COMPOST*));
+        compost_record[i]->x = x;
+        compost_record[i]->y = 127;
+        compost_record[i]->width = COMPOST_WIDTH;
+        compost_record[i]->height = 1;
+        x += 11;
+    }
+    
+    draw_compost();
 
 }
 
-COMPOST compost_get_info(int index){
-
+COMPOST* compost_get_info(int index){
+    return compost_record[index];
 }
 
 void compost_add(int index) {
@@ -28,13 +55,23 @@
 }
 
 void draw_compost(void){
+    
+    for (int i = 0; i < NUM_PILE; i++) {
+        int tly = 127 - COMPOST_WIDTH;
+        for (int j = 1; j <= compost_record[i]->height; j++) {
+            uLCD.BLIT(compost_record[i]->x,tly, COMPOST_WIDTH, COMPOST_WIDTH, compost_sprite);
+            tly -= COMPOST_WIDTH;
+        }
+    }
 
 }
 
 int get_compost_tallest_height() {
+    return 1;
 
 }
 
 int get_compost_height(int index) {
+    return compost_record[index]->height;
+}
 
-}
\ No newline at end of file