text: 
  #include <wire.h>
  #include "eload.h"
  
  const uint8_t cmd_str_reset[] = {EPOT_CMD_RESET,0x00};
  const uint8_t cmd_str_off[] = {EPOT_CMD_WRITE,EPOT_R_MIN};
  const uint8_t cmd_str_full[] = {EPOT_CMD_RESET,EPOT_R_MAX};
  
  uint8_t eload_state;
  uint8_t req_current;
  uint16_t raw_current;
  uint8_t actual_current;
  
  void eload_startup(void){
  
      //uncomment if using in stand allone application
      Wire.begin();
      eload_state = ELOAD_STATES_OFF;
      eload_reset();
  }
  
  void eload_loop(void){
  
      switch(eload_state){
          case ELOAD_STATES_ON :
                  currmon_read_current((uint8_t *)&raw_current,2);
  
                  actual_current = (uint8_t) (raw_current & 0xef00)>>8;
  
                  break;
  
          case ELOAD_STATES_OFF :
                  break;
      }
  }
  
  void eload_off(void){
      eload_write((uint8_t *)cmd_str_off, 2);
      eload_state = ELOAD_STATES_OFF;
  }
  
  /* Sets the demmmand current */
  /* Val is the current in amps */
  void eload_set_current(float val){
  
      req_current = val;
  
      //eload_on(val);
  
  }
  
  /**************** PRIVATE FUNCTIONS ********************/
  
  void eload_on(uint8_t val){
  
      uint8_t cmd_str[3];
  
      if(val < EPOT_R_MAX){
          req_current = val;
          cmd_str[0] = EPOT_CMD_WRITE;
          cmd_str[1] = val;
          eload_write((uint8_t *)cmd_str, 2);
  
          eload_state = ELOAD_STATES_ON;
      }
  }
  
  void eload_reset(void){
      eload_write((uint8_t *)cmd_str_reset, 2);
  }
  
  void currmon_read_current(uint16_t *ival, uint8_t sz){
  
      uint8_t cmd = CURRMON_REG_CURRENT;
  
      //set up the read pointer
      Wire.beginTransmission(EPOT_ADDR);
      Wire.write(&cmd,1);
      Wire.endTransmission();
      
      //read the current
      Wire.readTransmission(EPOT_ADDR,(uint8_t *)ival,sz);
  }
  
  void eload_read(uint8_t *bytes, uint8_t sz){
      Wire.readTransmission(EPOT_ADDR,bytes,sz);
  }
  
  void eload_write(uint8_t *bytes, uint8_t sz){
  
      Wire.beginTransmission(EPOT_ADDR);
      Wire.write(bytes,sz);
      Wire.endTransmission();
      
  }