Monday 26 December 2011

Connecting Arduino to Flight Simulator X


Introduction

Welcome to my tutorial on how to connect Arduino to Microsoft Flight simulator.
This is the easiest method I found.
FSX SDK exists but lacks of documentation, is not useful as it requires huge amount of code. I wanted something easy and after some research I was able to connect to FSX using the FSUIPC API. Please note that to get some of the functionality you have to register FSUIPC. And I thought sharing this with the world, maybe someone will benefit. In this ``tutorial`` I will explain the process and not just give you the code. I believe in understanding not just knowing.

 

System design

Amazing system design :)


Sorting files with php


This function will sort files in the directory passed as arguments by the last modified or created time
function sortFilesByDate($dirname)
{
clearstatcache();
$files = array();
if ($handle = opendir($dirname))
{
while (false !== ($file = readdir($handle)))
{
if ($file != "." && $file != "..")
{
$files[filemtime($dirname."/".$file)] = $file;
}
}
closedir($handle);
}
// sort
ksort($files);
end($files);
$tot = count($files);
$i = 0;
$EXITSTR = "";
while ($tot != $i)
{
$EXITSTR = $EXITSTR . current($files);
prev($files);
$i ++;
$EXITSTR = $EXITSTR . "<br/>";
}

 

return $EXITSTR;
}

MSN Style for user attention


What if your application is minimized and you want user attention
You can always do it with a message box.
But there is the msn style
That the icon in the taskbar "blinks"
How to do it??
Declaration

Imports System.Runtime.InteropServices

     _

Public Function FlashWindow(ByVal hwnd As Integer, ByVal bInvert As Integer) As Integer

    End Function

When you want to call this function you just FlashWindow(Me.Handle, 1)

But when you call this function the windows and the taskbar will "blink" one time
To achieve "msn style" put the call method into a timer (VB) for 490 ms and enable the tick tock :)
And when the user interacts with your form (got Focus???Click??? Your call but i suggest got Focus)
Hope this is useful 

Samsung NC10 recovery

lets say that you bought your nc10 and you install linux and you remove them later and you want to recover the data from Samsung recovery but you cant because F4 does not work anymore but you have access to the computer at least the command prompt.

What you can do?


Take your laptop to Samsung service and PAY!!!

OR

boot normaly to windows and open command prompt by Start -> start -> run Type CMD

when the command prompt open type diskpart let it start and type rescan and let the program finish rescanning the disks etc.
When the program finish scanning your disks type list disk you will see a list with your disks i suggest that if you have anything plugged to your computer remove it before and follow the procedure again and carefully

ok my pc is giving me one disk DISK 0

now type select disk 0 After type list partition it will give you 2 or 3 partition select the one that is type OEM by typing select partition 1(number depends)

now type active.

This is it now restart and the computer will boot to the recovery console!
Warning: if you do not want to make the oem disk bootable dont select you have to do the compleate recover so the recovery console will make your disk bootable again.

I try it and took me some while to repair the disk so Be carefull
I do not have any responsibility if you cannot fix your disk after!
By doing this steps you agreed that what you do and what happen is up to you.

Visual Basic .net enter key on textbox


If you ever wanted to capture the key Enter on a text box, here is the code

Private Sub txtsearch_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtsearch.KeyPress
   If Asc(e.KeyChar) = 13 Then
   'Your code goes here...
   End If
End Sub
The best method i found is to create a sub process and call it from both of your codes. Both codes i mean the button that you press the Enter key and the button that you have to handle the user input

Reset numbering for Screenshots Win+PrtSc

I was using today the screen shot functionality of Windows 8.1 Win Key + PrtSc How to reset the numbering?