working commands. singleton deleted

Dependents:   GonioTrainer

ReadCommand.cpp

Committer:
dkester
Date:
2015-06-07
Revision:
2:c9e47ac47edb
Parent:
1:fd4c0e2decb8
Child:
3:32afe87d4b62

File content as of revision 2:c9e47ac47edb:

#include "ReadCommand.h"
#include "OfflineCommand.h"

ReadCommand::ReadCommand(Storage* storage)
{
    this->storage = storage;
    this->running = 0;
    this->addr = 0x00;
}

void ReadCommand::initialize()
{
    printf("ReadCommand\n");
    setLed(1);
}

void ReadCommand::finish()
{
    setLed(0);
}


void ReadCommand::execute()
{
    //Read has nothing to do with the IMU interrupt
}

void ReadCommand::button()
{
    printf("**** BUTTON: ReadCommand    *****\n");

    __disable_irq();
    readFromMemory();
    __enable_irq();
}


void ReadCommand::readFromMemory()
{
    float angle;
    float gyro;

    for(int i = 0; i <= OfflineCommand::getLastAddress(); i = i + 4 ) {
        this->storage->read(i);

/*
        this->storage->readData();
        this->storage->readData();
        this->storage->readData();
        this->storage->readData();

        this->storage->endAction();

        angle = ((angle_H << 8) + angle_L) * 0.087912087;
        
        
        gyro = ((float)((imu_H << 8) + imu_L)) / 200;
        //float xgyro = ((float)sensors->getGyroX())/200;
     

        printf("Memory: angle = %.2f, gyroX =  %.4f\n", angle, gyro);
        */
    }


    printf("DONE!\n");
}