convert playing counts to unsigne dlong
authorJim Morris <morris@wolfman.com>
Thu, 3 Oct 2013 19:52:21 +0000 (12:52 -0700)
committerJim Morris <morris@wolfman.com>
Thu, 3 Oct 2013 20:32:28 +0000 (13:32 -0700)
src/modules/utils/panel/screens/WatchScreen.cpp
src/modules/utils/panel/screens/WatchScreen.h
src/modules/utils/player/Player.cpp
src/modules/utils/player/Player.h
src/modules/utils/player/PlayerPublicAccess.h

index e1371da..9a0dcb5 100644 (file)
@@ -207,7 +207,7 @@ void WatchScreen::display_menu_line(uint16_t line){
     switch( line ){
         case 0: this->panel->lcd->printf("H%03d/%03dc B%03d/%03dc", this->hotendtemp, this->hotendtarget, this->bedtemp, this->bedtarget); break;
         case 1: this->panel->lcd->printf("X%4d Y%4d Z%7.2f", (int)round(this->pos[0]), (int)round(this->pos[1]), this->pos[2]); break;
-        case 2: this->panel->lcd->printf("%3d%% %2d:%02d %3d%% sd", this->current_speed, this->elapsed_time/60, this->elapsed_time%60, this->sd_pcnt_played); break;
+        case 2: this->panel->lcd->printf("%3d%% %2ul:%02ul %3u%% sd", this->current_speed, this->elapsed_time/60, this->elapsed_time%60, this->sd_pcnt_played); break;
         case 3: this->panel->lcd->printf("%19s", this->get_status()); break;
     }
 }
index df4e8ea..eda7d83 100644 (file)
@@ -40,8 +40,8 @@ class WatchScreen : public PanelScreen {
         int bedtarget;
         int current_speed;
         double pos[3];
-        int elapsed_time;
-        int sd_pcnt_played;
+        unsigned long elapsed_time;
+        unsigned int sd_pcnt_played;
 };
 
 
index 5a73576..7be8939 100644 (file)
@@ -188,7 +188,7 @@ void Player::play_command( string parameters, StreamOutput* stream ){
     int result = fseek(this->current_file_handler, 0, SEEK_END);
     if (0 != result){
             stream->printf("WARNING - Could not get file size\r\n");
-            file_size= -1;
+            file_size= 0;
     }else{
             file_size= ftell(this->current_file_handler);
             fseek(this->current_file_handler, 0, SEEK_SET);
@@ -209,23 +209,23 @@ void Player::progress_command( string parameters, StreamOutput* stream ){
     }
 
     if(file_size > 0) {
-        int est= -1;
+        unsigned long est= 0;
         if(this->elapsed_secs > 10) {
-            int bytespersec= played_cnt / this->elapsed_secs;
+            unsigned long bytespersec= played_cnt / this->elapsed_secs;
             if(bytespersec > 0)
                 est= (file_size - played_cnt) / bytespersec;
         }
 
-        int pcnt= (file_size - (file_size - played_cnt)) * 100 / file_size;
+        unsigned int pcnt= (file_size - (file_size - played_cnt)) * 100 / file_size;
         // If -b or -B is passed, report in the format used by Marlin and the others.
         if ( options.find_first_of("Bb") == string::npos ){
-            stream->printf("%d %% complete, elapsed time: %d s", pcnt, this->elapsed_secs);
+            stream->printf("%u %% complete, elapsed time: %lu s", pcnt, this->elapsed_secs);
             if(est > 0){
-                stream->printf(", est time: %d s",  est);
+                stream->printf(", est time: %lu s",  est);
             }
             stream->printf("\r\n");
         }else{
-            stream->printf("SD printing byte %ld/%ld\r\n", played_cnt, file_size);
+            stream->printf("SD printing byte %lu/%lu\r\n", played_cnt, file_size);
         }
 
     }else{
index 4f56edd..dd6c2f9 100644 (file)
@@ -49,8 +49,8 @@ class Player : public Module {
         StreamOutput* current_stream;
         StreamOutput* reply_stream;
         FILE* current_file_handler;
-        long file_size, played_cnt;
-        int elapsed_secs;
+        unsigned long file_size, played_cnt;
+        unsigned long elapsed_secs;
 };
 
 #endif // PLAYER_H
index 88d8fc6..20c298d 100644 (file)
@@ -7,7 +7,7 @@
 #define get_progress_checksum     CHECKSUM("progress")
 
 struct pad_progress {
-    int percent_complete;
-    int elapsed_secs;
+    unsigned int percent_complete;
+    unsigned long elapsed_secs;
 };
 #endif