Gast
#1757868
Guten Tag!
Ich habe ein Projekt an der Uni mit dem Embedded Master TFT. Dieser soll
mit .Net Mikro Framework programmiert werden. Mein Problem ist nun, dass
ich werte vom adc dauerhaft auslesen und auf dem tft ausgeben möchte
aber nicht weiß wie ich das anstellen soll. das auslesen und ausgeben
des adc wertes auf dem tft funktioniert bisher nur durch drücken eines
buttons.
Ich habe schon einiges versucht aber immer wenn ich eine while(true)
endlosschleife verwende, zeigt er mir nichts an. Ich habe mal meinen
Code soweit verkürzt wie ich denke, dass es zum verständnis reicht. Sry,
falls es immernoch zu lang sein sollte, aber ich denke mal, so kann mir
eher jemand helfen.
namespace ProjektA
{
public class Program : Microsoft.SPOT.Application
{
static PersistentStorage ps;
public static void Main()
{
Program myApplication = new Program();
Window mainWindow = myApplication.CreateWindow();
// Create the object that configures the GPIO pins to buttons.
GPIOButtonInputProvider inputProvider = new
GPIOButtonInputProvider(null);
// Start the application
myApplication.Run(mainWindow);
}
private Window mainWindow;
ListBox listBox = new ListBox();
public Window CreateWindow()
{
listBox.Items.Add(text);
// Add the text control to the window.
mainWindow.Child = listBox;
// Connect the button handler to all of the buttons.
mainWindow.AddHandler(Buttons.ButtonUpEvent, new
ButtonEventHandler(OnButtonUp), true);
// Set the window visibility to visible.
mainWindow.Visibility = Visibility.Visible;
// Attach the button focus to the window.
Buttons.Focus(mainWindow);
return mainWindow;
}
private void OnButtonUp(object sender, ButtonEventArgs e)
{
for (int i = 0; i < 50; i++) //50 Messungen in 500ms vornehmen
{
value += adcmessung.GewichtAuslesen(); //ADC Wert auslesen
Thread.Sleep(10); //10ms warten
}
value = value / 50; //Mittelwert
string W = string.Concat("Wert: ", value.ToString("N"), "
kg");//"N" für zwei Nachkommastellen mit runden
listBox.Dispatcher.BeginInvoke(new
DispatcherOperationCallback(UpdateText), new object[] { W });
if (listBox.Items.Count >= 15)
{
listBox.Items.Clear();
}
}
Ich hoffe, mir kann da jemand helfen, denn so langsam gehen mir die
Ideen aus... :(
Vielen Dank schonmal!