TO CHECKOUT

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
chrish
Date:
Tue Dec 02 13:29:16 2014 +0000
Parent:
0:785c2b62c4d1
Commit message:
Nr2

Changed in this revision

lab.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/lab.cpp	Sat Nov 29 17:48:10 2014 +0000
+++ b/lab.cpp	Tue Dec 02 13:29:16 2014 +0000
@@ -70,11 +70,17 @@
 byte bRGB565ToGray(word wColor){
     byte bGray = 0;
     byte r,g,b;
+    
     r = (wColor & 0xf800)>>11;
     g = (wColor & 0x07E0) >>5;
     b = (wColor & 0x001F) ;
+    #if 1 
+    bGray = ((r+b)*2 + g)/3; 
+        
+    #else 
     
-    bGray = ((r+b)*2 + g)/3; 
+    bGray  = (byte)     
+    #endif 
          /*
      .... hier eigenen Code eintragen
      */
@@ -107,7 +113,7 @@
 
 /* Grauwertbild in Sektor 2 plazieren */
 void vGrayToScreen2(byte *pGray){
-    word wColor, w, v;
+    word wColor, v;
     byte x, y;
     x = y = 0;
     for(v = 0; v < 19200; v++){
@@ -125,7 +131,7 @@
 /* Grauwertbild in Sektor 3 plazieren */
 void vGrayToScreen3(byte *pGray){
  
-  word wColor, w, v;
+  word wColor, v;
     byte x, y;
     x = y = 0;
     for(v = 0; v < 19200; v++){
@@ -144,7 +150,7 @@
 
 /* Histogramm in Sektor 4 zeichnen */
 void vDrawHisto(byte *pGray){
-    word v, y, wMax = 0;
+    word y, wMax = 0;
     byte i, j, n;
     /* Histogrammvektor initialisieren ... ihre Sache */
 
@@ -201,46 +207,53 @@
    bValue bestimmt die Größenmanipulation
    */
 void vChangeGray(byte *pGray, byte bValue){
-       byte bGMin, bGMax, wMax;
-    word x,y;
-    //fpAdcValue
-     bGMin = 20;
-     bGMax = 40;
-   //  wMax = 64 * fpAdcValue;
-          wMax = 255 * fpAdcValue;
+       byte bGMin, bGMax, bWMax,bWMin;
+    word x,y,l,h;
+    word wColor ;
+     bWMax = 63;
+     bWMin = 0;
+   
+   for(x=0;x<64;x++)if( awHisto[x] > 0){ bGMin = x; break;}
+   // Ermittlung von gMax
+   for(x=63;x>=0;x--)if( awHisto[x] > 0){ bGMax = x; break;}
+   
+   lcd_drawNumber(&myLCD, bGMin, 1, 230, 1, BLACK);
+   lcd_drawNumber(&myLCD, bGMax, 50, 230, 1, BLACK);
 
-     
+   
+   byte abOnePiktureLine[160];
+   // Jetzt Ermittlung der Neuen Werte mit Transferfunktion 
+   // gneu (g) = (g- gmin) * (   (wmax+ wmin) / ( gmax - gmin ) ) 
        byte *ab=  &abPicture[0][0];
-    #if 0
-      for(x = 0; x < 100; x++){
-        if( ( ( *(ab + x) - bGMin) * (wMax/(bGMax+bGMin)) ) >=0) 
-              *(pGray + x) = ( *(ab + x) - bGMin) * (wMax/(bGMax+bGMin));
+    #if 1
+    /**Überschreiben des Grauwertbildes Mit neuem Bild */
+      for(x = 0; x <19200; x++){
+        if( ( ( *(ab + x) - bGMin) * (bWMax/(bGMax-bGMin)) ) >=0) 
+              *(pGray + x) = ( *(ab + x) - bGMin) * (bWMax/(bGMax-bGMin)) * bValue   ;
               else 
             *(pGray+x) =0;
          }
         
     #else
-    for(x = 0; x < 100; x++){
-        if( ( ( *(ab + x) - bGMin) * (wMax/(bGMax+bGMin)) ) >=0) 
-              *(ab + x) = ( *(ab + x) - bGMin) * (wMax/(bGMax+bGMin));
+    /** Keine Speicherung des Korregierten Bildes sondern Direkte Ausgabe aus screen */
+    // l = x  h = y 
+    l=0;
+    h=0;
+      for(x = 0; x <19200; x++){
+        if( ( ( *(ab + x) - bGMin) * (bWMax/(bGMax-bGMin)) ) >=0) 
+              wColor = wGrayToRGB565(( *(ab + x) - bGMin) * (bWMax/(bGMax-bGMin)) ) /*bValue */  ;
               else 
-            *(ab+x) =0;
+           wColor = wGrayToRGB565(0);
+           
+           lcd_setPixel(&myLCD, h, 160 + l, wColor);
+           h++;
+            if(h > 119){
+            h= 0;
+            l++;
+            }
          }
     #endif
-      /*  for(y=0;y<120;y++)
-            for(x=0;x<160;x++){
-              if( ( (abPicture[y] - bGMin) * (wMax/(bGMax+bGMin)) ) >=0) 
-              pGray[y] = (byte)(abPicture[[x] - bGMin) * (wMax/(bGMax+bGMin));
-              else 
-              pGray[y] =0;
-             
-        }*/
-    
-    
-    
-    /*
-    ...   Sie sind dran
-    */
+
     }
 
 
@@ -282,15 +295,17 @@
     byte abPictureCorrektet[120][160];
     
      fpAdcValue = fpAnalog.read();
-     lcd_drawFloat(&myLCD,fpAdcValue*3.3, 3, 20, 125, 1, RED);
+     lcd_drawFloat(&myLCD,fpAdcValue*10, 3, 20, 125, 1, RED);
       if(!bBtn1) {
       
-              vChangeGray(&abPictureCorrektet[0][0], 4);
+            //  vChangeGray(&abPictureCorrektet[0][0], 4);
               #if 0
               vGrayToScreen3(&abPictureCorrektet[0][0]);
                 #else
-                              vGrayToScreen3(&abPicture[0][0]);
-
+                          vChangeGray(&abPicture[0][0], fpAdcValue*10);
+                           vGrayToScreen3(&abPicture[0][0]);
+                          vDrawHisto(&abPicture[0][0]);
+                            
                 #endif
         }
    }