n97_as_compass.txt 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. link: http://wiki.forum.nokia.com/index.php/How_to_turn_the_N97_into_a_Magnetic_Compass
  2. TInt i = 0;
  3. CSensrvChannelFinder* finder = CSensrvChannelFinder::NewLC();
  4. RSensrvChannelInfoList channelList;
  5. CleanupClosePushL( channelList );
  6. TSensrvChannelInfo Channelinfo;
  7. finder->FindChannelsL( channelList, Channelinfo );
  8. for (i = 0; i<channelList.Count(); i++)
  9. {
  10. Channelinfo = channelList[i];
  11. switch(Channelinfo.iChannelType)
  12. {
  13. case KSensrvChannelTypeIdMagneticNorthData:
  14. iBoolMagSupported = ETrue;
  15. break;
  16. default:
  17. iBoolMagSupported = EFalse;
  18. break;
  19. }
  20. if(iBoolMagSupported == (TInt)ETrue)
  21. {
  22. break;
  23. }
  24. }
  25. if(iBoolMagSupported == (TInt)EFalse)
  26. {
  27. User::Leave(KErrNotSupported);
  28. }
  29. if ( channelList.Count() > 0 )
  30. {
  31. Channelinfo = channelList[i];
  32. iMagneticNorthSensor = CSensrvChannel::NewL( channelList[ i ] );
  33. iMagneticNorthSensor->OpenChannelL();
  34. iMagneticNorthSensor->StartDataListeningL( this, 1, 1, 0 );
  35. }
  36. channelList.Close();
  37. CleanupStack::Pop( &channelList );
  38. CleanupStack::PopAndDestroy( finder );