No Description

MAX5487Example.java 2.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * Author: Abhishek Malik <abhishek.malik@intel.com>
  3. * Copyright (c) 2016 Intel Corporation.
  4. *
  5. * Permission is hereby granted, free of charge, to any person obtaining
  6. * a copy of this software and associated documentation files (the
  7. * "Software"), to deal in the Software without restriction, including
  8. * without limitation the rights to use, copy, modify, merge, publish,
  9. * distribute, sublicense, and/or sell copies of the Software, and to
  10. * permit persons to whom the Software is furnished to do so, subject to
  11. * the following conditions:
  12. *
  13. * The above copyright notice and this permission notice shall be
  14. * included in all copies or substantial portions of the Software.
  15. *
  16. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  17. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  18. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  19. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  20. * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  21. * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  22. * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  23. */
  24. import upm_max5487.MAX5487;
  25. public class MAX5487Example {
  26. static {
  27. try {
  28. System.loadLibrary("javaupm_max5487");
  29. System.loadLibrary("mraajava");
  30. } catch (UnsatisfiedLinkError e) {
  31. System.err.println(
  32. "Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" +
  33. e);
  34. System.exit(1);
  35. }
  36. }
  37. public static void main(String[] args) {
  38. // TODO Auto-generated method stub
  39. //! [Interesting]
  40. MAX5487 sensor = new MAX5487(7);
  41. // Power LED UP
  42. for(int i=0; i<255; i++){
  43. sensor.setWiperA((short)i);
  44. try {
  45. Thread.sleep(5);
  46. } catch (InterruptedException e) {
  47. // TODO Auto-generated catch block
  48. System.out.println("The following Exception occured: "+e.getMessage());
  49. }
  50. }
  51. // Power LED DOWN
  52. for(int i=0; i<255; i++){
  53. sensor.setWiperA((short)(255 - i));
  54. try {
  55. Thread.sleep(5);
  56. } catch (InterruptedException e) {
  57. // TODO Auto-generated catch block
  58. System.out.println("The following exception occured: "+e.getMessage());
  59. }
  60. }
  61. System.out.println("Exiting...");
  62. //! [Interesting]
  63. }
  64. }